Getting the current month with code

BukHix

Registered User.
Local time
Today, 14:10
Joined
Feb 21, 2002
Messages
379
I can get the current date with this:

Dim dtDate As Date
dtDate = Format(Date, "mm/dd/yy")

Is there a constant for months? I mean is there I way I can convert this code to the month at the time the code is run? I have a report that I want to filter by the current month. So if the code was run now I would only get the records for march.

This is the code I am workin on:

DoCmd.OpenReport "EmpContactLog", acViewPreview, , "[Month] = '" & strMonth & "'"
 
I think (not promising anything) that this will do the job

DoCmd.OpenReport "EmpContactLog", acViewPreview, , "[Month] = Format(Date, mm)

mm = 01-12
mmm = Jan-Dec etc
 
Correct syntax is
format(date(), "mmm")
to get the full month name instead of the ordinal.

Alex
 
Thanks it worked but I have one more question. The code returns the months number which is ok but can I convert it to a name? So instead of 3 I would get March.
 
Oops I forgot to unrem the line with the format change. I was still using the two m's insead of the three.

Here is what it looks like:

Code:
Dim dtDate2 As String
dtDate2 = Format(Date, "mmm")
DoCmd.OpenReport "repEmpUpdates", acViewPreview, , _
    "[Month] = '" & dtDate2 & "'"



[This message has been edited by BukHix (edited 03-22-2002).]
 

Users who are viewing this thread

Back
Top Bottom