DateSerial reference to last year

  • Thread starter Thread starter njhildebrand
  • Start date Start date
N

njhildebrand

I have the following in a query criteria:
=DateSerial(Year([Enter start date]),Month([Enter start date])-1,1)
And <=DateSerial(Year([Enter end date]),Month([Enter end date]),1)

It works when another field text box is checked (ex:
ENDofMONTH_Production)

All last year this query pulled over production from the previous month
(of the entered date range) as long as the ENDofMonth_Production box
was checked. Now that we are in a new year, it is not pulling the the
production with the box checked.

Anyone know what is happing here???
Thanks in advance for your help!

Curiously Frustrated
 
Hi njhildebrand,

It should still work for Feb (2nd Month of the year). It will not work for
the 1st month of the year. I do not know how Access interpret
DateSerial("2005/00").

Alternative way to get the previous month is using Dateadd with "-1" to the
month.

DateAdd("m", -1, Now())

Hope this helps.


I have the following in a query criteria:
=DateSerial(Year([Enter start date]),Month([Enter start date])-1,1)
And <=DateSerial(Year([Enter end date]),Month([Enter end date]),1)

It works when another field text box is checked (ex:
ENDofMONTH_Production)

All last year this query pulled over production from the previous month
(of the entered date range) as long as the ENDofMonth_Production box
was checked. Now that we are in a new year, it is not pulling the the
production with the box checked.

Anyone know what is happing here???
Thanks in advance for your help!

Curiously Frustrated
 
Using the below code, where would I put that DateAdd?
=DateSerial(Year([Enter start date]),Month([Enter start dat­e])-1,1)


And <=DateSerial(Year([Enter end date]),Month([Enter end dat­e]),1)
Thanks,
Norma
 
Using the below code, where would I put that DateAdd?
=DateSerial(Year([Enter start date]),Month([Enter start dat­e])-1,1)


And <=DateSerial(Year([Enter end date]),Month([Enter end dat­e]),1)
Thanks,
Norma
 
Using the below code, where would I put that DateAdd?
=DateSerial(Year([Enter start date]),Month([Enter start dat­e])-1,1)


And <=DateSerial(Year([Enter end date]),Month([Enter end dat­e]),1)
Thanks,
Norma
 
JL said:
Hi njhildebrand,

It should still work for Feb (2nd Month of the year). It will not
work for the 1st month of the year. I do not know how Access
interpret DateSerial("2005/00").

DateSerial is fully aware of how to "wrap" in both positive and negative
directions. The zeroth month is simply the last month of the previous year.
 
Back
Top