Month(Date) and Day(Date)

Tieval

Still Clueless
Local time
Today, 00:33
Joined
Jun 26, 2015
Messages
475
I am defining a document name using the following:

Code:
CoCName = "COC" & Right(Year(Date), 2) & Month(Date) & Day(Date)

Last month this returned, for example, COC161225 on Christmas Day but today it returns COC1715 and I am trying to return COC170105.

Is there a way to get it to return the month and day as two figures always?
 
Try using
Format(Datepart("m",Date()),"00")
and similar for the Day part
 
Perfect and many thanks, I obviously had too much Christmas :o
 
You could use the following:

Format(Date,"yymmdd")
 

Users who are viewing this thread

Back
Top Bottom