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

Last day of previous month

Status
Not open for further replies.

goslincm

MIS
May 23, 2006
292
US
Good afternoon. I am using the following in my query:

Format(DateSerial(Year(Date()),[FiscalEndMM],1),"mm/"01"/"yyyy")

The problem I have found is that where I have the day of the month setting to 01, I'm told it should be set to the last day of the month.

How can I do that?
 
Hello:

=DateSerial(Year(Date()), Month(Date()), 0)

will give you the last day of the previous month based on today's date:

Regards
Mark
 
Format(DateSerial(Year(Date()),[FiscalEndMM]+1,0),"mm/dd/yyyy")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks Mark, but in looking back I didn't explain as well as I could have. What I am doing, is taking a field called [FiscalEndMM] which represent the month a companies fiscal year ends, and combining that numeric representation of the month, with the current year.

So if there fiscal year ends in January, I would get 01/01/2007. I need however, do be able to pick up the last day of the month for whatever month is being represented in the field [FiscalEndMM].

So in my example above, I need a way to get: 1/31/2007

 
That was my understanding, so simply try my suggestion above.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top