Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Beginning and End Date of a Month

Status
Not open for further replies.
Feb 20, 2002
64
US
Is there a Function or a method I can use to populate columns with the month's 1st and last date given any particular date??

In other words, if I had RPT_RUN_DATE = 03/27/2003.

3 = March
1 = January

Can I take ( 3/27/2003 - DateValue(2Monthes) ) = 1/27/2003


BeginDate(January) or BeginDate(1) = 1/1/2003 = REPORTBEGINDATE
EndDate(January) or EndDate(1) = 1/31/2003 = REPORTENDDATE

If clarification is needed, please request.

Thank you.
 
if you use the datediff function and isolate the month the day should remain the same.

datediff("m",-2,yourdate) 'i.e. 3/27/03

typically if you go to the first of the next month and back up 1 day that is the end of the month.

datediff("d",-1,"02/01/03") gives 1/31/03
 
but the first of a give month is:

MyDate = Date
? DateSerial(Year(Mydate), Month(Mydate), 1)
4/1/03
and the last date of a given date is (similar):
? DateSerial(Year(Mydate), Month(Mydate) + 1, 0)
4/30/03


MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top