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

Date 1

Status
Not open for further replies.

slickp

Technical User
Feb 15, 2006
35
GB
Using crystal 10, i am trying to create a formula that will give me the final day of the month, 3 months back from the currentdate month. So far i have this :

if Month (CurrentDate) = 1 then date ((Year (CurrentDate)-1), 09, 30) else
if Month (CurrentDate) = 2 then date ((Year (CurrentDate)-1), 10, 31) else
if Month (CurrentDate) = 3 then date ((Year (CurrentDate)-1), 11, 30) else
if Month (CurrentDate) = 4 then date ((Year (CurrentDate)-1), 12, 31) else
if Month (CurrentDate) = 5 then date (Year (CurrentDate), 01, 31) else
if Month (CurrentDate) = 6 then date (Year (CurrentDate), 02, 28) else
if Month (CurrentDate) = 7 then date (Year (CurrentDate), 03, 31) else
if Month (CurrentDate) = 8 then date (Year (CurrentDate), 04, 30) else
if Month (CurrentDate) = 9 then date (Year (CurrentDate), 05, 31) else
if Month (CurrentDate) = 10 then date (Year (CurrentDate), 06, 30) else
if Month (CurrentDate) = 11 then date (Year (CurrentDate), 07, 31) else
if Month (CurrentDate) = 12 then date (Year (CurrentDate), 08, 31)

Which is great, however does anyone have any ideas of how i can cater for a leap year, so that when the month is june the formula will return the date 29th Feb when it is a leap year?

Cheers
 
i cant think of an easy way to get the last day of that month but you could go backwards. so for your example, you would want the formula to create 1st march minus 1

eg
to get last day in Feb
date((Year(CurrentDate)-1), 03, 01) -1
 
Good idea, cheers for that mate
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top