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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

finding the last day of the previous month 1

Status
Not open for further replies.

smiley0q0

Technical User
Feb 27, 2001
356
US
i have fields that contain one date of every month for the past year, they are all different. i need to find the last day of the previous month for each of those fields. i won't know what the date is in the date field, it varies everyday. how would i do this?

thanks in advance :-9
 
i don't quite understand... cannot you elaborate a little.

the date fields are dynamic, the formula i use to bring up the date for 12 months ago is:
=DateAdd("d",IIf(Format((DateAdd("m",-12,Date())-1),"ddd")="Sat",-1,IIf(Format((DateAdd("m",-12,Date())-1),"ddd")="Sun",-2,0)),DateAdd("m",-12,Date())-1)

for this result i need to find the last day of the month 13 months ago.
 
If you want to know the last date of the prior month based on today, the DateSerial function will provide it.

Example: DateSerial(Year(Date()), Month(Date()),0)

If Date() returns 3/23/2001 then above would return 2/28/200.


In your case you can substitute DateAdd("m",-12,Date())-1) for Date() as in

DateSerial(Year(DateAdd("m",-12,Date())-1), Month(DateAdd("m",-12,Date())-1),0)


Dave
 
AWESOME!!!!! THANK YOU!! works like a charm :-V :-D
 
Actually, neufarth's first answer is easier, if you just follow the logic one more step.

MyDate: DateSerial(Year([DateField]), Month([DateField], 0)

returns the last day of the previous month for any Date in [DateField].

like Mikey says, "Try it, You'll Like It"





MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top