G
Guest
How do I convert a string to a date? An example of my string is "05262007".
Thanks.
Thanks.
Douglas J. Steele said:Actually, it's even easier than that:
ItsADate = CDate(Format("05262007", "##/##/####"))
Of course, this method (and yours) will only work when the user's Short
Date format is mm/dd/yyyy (or something like yyyy-mm-dd or dd mmm yyyy).
In other words, it won't work if the user's Short Date format is
dd/mm/yyyy, since CDate is one of the few built-in Date functions that
actually respects the user's settings.
To be absolutely certain, use
ItsADate = DateSerial(Right("05262007",4), Left("05262007",2),
Mid("05262007",3,2))