View Full Version : Format Date and Time


cameron.scrimgeour
09-15-2009, 12:08 AM
Used to using Oracle so not sure how to do this in Access.

I need to change the format of a date and time from...

01/08/2009 12:00:00

to

01-Aug-2009 12:00:00

How can I do this?

Would usually use to_Date in Oracle, but think I need to use something like the following...

FORMAT(#01/08/2009 12:00:00#, 'dd-Mon-yyyy HH:MM:SS')

But this doesnt seem to work right as I get a data type mismatch error.

Help?

namliam
09-15-2009, 12:28 AM
Try looking up the Format function in the Access help
In Access getting more of the same is simply adding on the letters
d
dd
ddd
dddd

m
mm
mmm
mmmm

Both go from 1 didget (8 for aug), 2 didget ( 08 ) to 3 char (Aug) to full (August)
Course d does it for days....

Good luck !

DCrake
09-15-2009, 12:31 AM
Slight syntax change required

From
FORMAT(#01/08/2009 12:00:00#, 'dd-Mon-yyyy HH:MM:SS')

To
Format(#01-08-2009 12:00:00#, "dd-mmm-yyyy hh:nn:ss")

Or

Format(AnyDate, "dd-mmm-yyyy hh:nn:ss")
Format(Now(), "dd-mmm-yyyy hh:nn:ss")