IIF(FormatDateTime....

dj59

Registered User.
Local time
Today, 09:17
Joined
Jul 27, 2012
Messages
70
MS Access 2010
My query reflects a date field.
some dates reflect as this format:
1/19/2013 12:00:36 AM
some dates reflect as this format:
1/19/2013

I want to use the query builder to say:
IF date format is like 1/19/2013 12:00:36 AM, then something.....
IF not, then something else.

I tried this, but it doesn't work:
type: IIf( FormatDateTime(datefieldname, 4) , "true", "false")

In the table I am using in this query the data type is Date/Time, the format is blank.
Thanks for any info on this.
 
You do not need the IIF statement. Just use the Format function like:

Code:
YourDate: Format([YourDateField],"mm/dd/yyy")

In the code above, just change the "YourDate:" to what you want the output field to be named and replace the "YourDataField" with the acdtual name of your field.
 
dj59, your requirement is a bit unclear.. Do you want to show True if the Format is 22/01/2013 17:07:42 and False if not??

If that is the case.. Try the following..
Code:
IIF(Len([I]datefieldname[/I]) > 10, "True", "False")
If you need to make the Date in a set format, follow Mr.B's suggestion..
 
Last edited:

Users who are viewing this thread

Back
Top Bottom