Re: Convert DateTime to Date
The milliseconsd can't be handled. Removing it will use PC regional settings for parsing the date in the string. Still, it would be best to manually parse the string (your gonna modify the string anyway to remove the millisecond info) if you know its format and create the date using DateSerial() so you can avoid issues with regional settings.
Re: Convert DateTime to Date
Yes you can use Format
MsgBox Format(Now, "dd/mmm/yyyy")
Well it works for Now. ;)
Now is a Date and Time.
Re: Convert DateTime to Date
Thanks Keith, but the point is that "2005-07-13 00:00:00.000" is not the same as Now and it isn't a Date. :rolleyes:
I think I'll follow what leinad31 said and use DateSerial.
Re: Convert DateTime to Date
Yes but the reason your doesn't work is
Format("2005-07-13 00:00:00.000", "dd/mmm/yyyy")
Incorrect time value
Format("2005-07-13 13:05", "dd/mmm/yyyy")
This works. ;)
Re: Convert DateTime to Date
It will work now, but it may not work later.. it'll be vulnerable to user changes to short/long date format.
Re: Convert DateTime to Date
Just remove the milliseconds, and then you will have a valid date format:
Format(Split("2005-07-13 00:00:00.000", ".")(0), "dd/mmm/yyyy")
And since you don't use the time, you might as well, remove everything from the right of the space...
Format(Split("2005-07-13 00:00:00.000", " ")(0), "dd/mmm/yyyy")