Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting text Field to Date

Status
Not open for further replies.

truitt20

Technical User
Dec 10, 2004
74
US
Currently a linked table has a "Date" field that is data type text. Field is populated as such:

20070418

I have written an expression to get it 04/18/2007, but when i try to link to other tables via queries I get the wonderful data type mismatch b/c the other tables are all using data type Date/Time. Any way to get around this?

thanks

 




Hi,

"I have written an expression to get it 04/18/2007..."

Just because the data LOOKS like 04/18/2007, does not necessarlily mean that it's a REAT DATE.

What is your expression?

Does your expression CONVERT the TEXT to a REAL DATE? That is what you need to do if you are comparing this with other DATES.

Skip,

[glasses] [red][/red]
[tongue]
 
My expression looks like:

Period End Date: Mid(SPC_StdPos_D![Period End Date],5,2) & "/" & Right(SPC_StdPos_D![Period End Date],2) & "/" & Left(SPC_StdPos_D![Period End Date],4)

I also tried to format the field properties to short dat as well, but to no avail.

thanks
 
You need to coerce your output into a date using the CDate function:
[tt]
Period End Date: CDate(Mid(SPC_StdPos_D![Period End Date],5,2) & "/" & Right(SPC_StdPos_D![Period End Date],2) & "/" & Left(SPC_StdPos_D![Period End Date],4))[/tt]

HTH,
Larry
 
Perfect! Thank guys. Never new of the CDate function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top