Month(Date) and Day(Date) (1 Viewer)

Tieval

Still Clueless
Local time
Today, 04:32
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?
 

Minty

AWF VIP
Local time
Today, 04:32
Joined
Jul 26, 2013
Messages
10,371
Try using
Format(Datepart("m",Date()),"00")
and similar for the Day part
 

Tieval

Still Clueless
Local time
Today, 04:32
Joined
Jun 26, 2015
Messages
475
Perfect and many thanks, I obviously had too much Christmas :eek:
 

stopher

AWF VIP
Local time
Today, 04:32
Joined
Feb 1, 2006
Messages
2,395
You could use the following:

Format(Date,"yymmdd")
 

Users who are viewing this thread

Top Bottom