Month 01

1. Senior Member
Join Date
Dec 1969
Posts
1,045

## Month 01

I&#039;m trying to write the correct syntax for writing the current month so that if the current month is a single digit then it displays the current month like this: 08 as apposed to just 8<BR><BR>Here is what I have so far:<BR><BR>dtTest = Now()<BR>dtTest = DateAdd("m", 0, dtTest) <BR><BR>fileYM = Right(Year(dtTest), 4) & Left(Month(dtFile), 2) & ".dat" <BR>

2. Senior Member
Join Date
Dec 1969
Posts
220

## RE: Month 01

Here&#039;s how I&#039;d do it...<BR><BR>mm = month(dtTest)<BR>if mm &#060; 10 then mm = "0" & mm end if<BR>fileYM = year(dtTest) & mm & ".dat"<BR>

3. Senior Member
Join Date
Dec 1969
Posts
2,225

## Just check the length

dtTest = Now()<BR>strTheMonth = Month(dtTest)<BR>If len(strTheMonth) = 1 Then<BR>strMonth = "0" & strMonth<BR>End If<BR><BR>Note: Code is untested.<BR><BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
355

## RE: Just check the length

dtTest = Now()<BR>strTheMonth = Right( "0" & Month(dtTest), 2 )

5. Senior Member
Join Date
Dec 1969
Posts
2,225

## Works too

and with less code.

6. Senior Member
Join Date
Dec 1969
Posts
1,045

## THANKS GUYS!!

&#060;&#062;

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•