DateSerial reference to last year

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
 
G

Guest

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
 
N

njhildebrand

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
 
N

njhildebrand

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
 
N

njhildebrand

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
 
R

Rick Brandt

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top