Length of Character


Posted by BobJ on January 04, 2002 5:50 AM

I need to take the result(In VBA) of Day(now()), which would
equal 4 (1/4/02) and turn it into a two character
field (04) , ultimately, I want it to be two characters on MM,
two on DD and 4 on YYYY.

Below is some code I wrote to get around it but I am sure there is a better way.

'Date Checks
MM = Month(Now)
If Len(MM) = 1 Then MM = "0" & MM
DD = Day(Now)
If Len(DD) = 1 Then DD = "0" & DD
YYYY = Year(Now)
'Date Layout
TDay = YYYY & MM & DD


Thanks! Bj


Posted by Bariloche on January 04, 2002 6:11 AM

Bob,

Will the following work for you (modified as necessary, of course):


Cells(1, 1).Value = Format(Date, "yyyyddmm")


enjoy




Posted by Bariloche on January 04, 2002 6:13 AM

oops, should read "yyyymmdd" (NT)

Will the following work for you (modified as necessary, of course):