ghettocounselor
asked on
MS ACCESS text datetime field compared with datereltoday in query
I have a text field called CUSTOM_FIELD with date time data: 201312092304
And I'd like to do a where statement against this but will need to convert/format the data as a proper date in the process; something like this eventually once formated ((PHM_ENHANCED_CHGS.CUSTOM _FIELD)=DA TERELTODAY (-1)))
And I'd like to do a where statement against this but will need to convert/format the data as a proper date in the process; something like this eventually once formated ((PHM_ENHANCED_CHGS.CUSTOM
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yeah, that would work too Miriam. Why do I always seem to look for the function when a simple formatting would work? ;-)
Although the formatting of the [CUSTOM_FIELD] appears to include HHMM as well, so the OP might need to try:
PHM_ENHANCED_CHGS.CUSTOM_F IELD = Format(DATERELTODAY(-1),"Y YYYMMDDHHN N")
if the hour and minute are critical.
Although the formatting of the [CUSTOM_FIELD] appears to include HHMM as well, so the OP might need to try:
PHM_ENHANCED_CHGS.CUSTOM_F
if the hour and minute are critical.
ASKER
This worked as advertised.
So, rather than try to create a complicated string of Lefts, mids, rights, ..., I would recommend you write a function to do the conversion for you, then call the function and pass it the value of your Custom_Field. An example might look like:
Open in new window
and your where clause might look like:WHERE ConvDate(PHM_ENHANCED_CHGS