Dates

  • Thread starter Thread starter quixote
  • Start date Start date
Q

quixote

I have created a report and ran into a problem when the
year changed. In the report I must show Previous month as
a field and Year as a field. I want to run this report on
the first day of every month for the previous month. My
problem is...how in January do I make sure that I get data
for December of the previous year. This "DatePart
("yyyy",Now())" won't work in Jan.
Thanks
 
yourDate = DateSerial(Year(Date), Month(Date), 1 - 1)

This code gives You last day of previous month.
 
quixote said:
I have created a report and ran into a problem when the
year changed. In the report I must show Previous month as
a field and Year as a field. I want to run this report on
the first day of every month for the previous month. My
problem is...how in January do I make sure that I get data
for December of the previous year. This "DatePart
("yyyy",Now())" won't work in Jan.

Try using:
Month(DateSerial(Year(Date()), Month(Date()) - 1, 1))
Year(DateSerial(Year(Date()), Month(Date()) - 1, 1))
 
Back
Top