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

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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;
 
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]
 
Back
Top