1st date, and last date of a given month in access?

G

Guest

How do I find the date, of the 1st day, and the last day of a given month. I
want to use this in monthly reports that give a heading reqirement: from 1
(month) (year) to xx (month) (year) same month, and same year, just need
first and last dates.
 
P

pietlinden

SELECT Orders.OrderDate,
DateSerial(Year([OrderDate]),Month([OrderDate]),1) AS FirstOfMonth,
DateAdd("d",-1,DateSerial(Year([OrderDate]),Month([OrderDate])+1,1)) AS
LastOfMonth
FROM Orders;
 
J

John Vinson

SELECT Orders.OrderDate,
DateSerial(Year([OrderDate]),Month([OrderDate]),1) AS FirstOfMonth,
DateAdd("d",-1,DateSerial(Year([OrderDate]),Month([OrderDate])+1,1)) AS
LastOfMonth
FROM Orders;

Or even more simply: DateSerial(Year([OrderDate]), Month([OrderDate])
+ 1, 0)

The zeroth of a month is the last day of the previous month -
DateSerial is clever enough to do that and more!

John W. Vinson[MVP]
 

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