garyjgs
asked on
Crystal Reports Current Date
There are a series of dates in a formula for a Crystal Report. The date is expressed in the formula as: date(2012,01,01). How can the year 2012 be changed to identify "current year" as not have to change the formula every year?
try Year(CurrentDate)
Looks good
mlmcc
mlmcc
In full that would be
Date(Year(CurrentDate), 1, 1)
Date(Year(CurrentDate), 1, 1)
ASKER
I have attached a screen print of what I am trying to accomplish with current year
formula-screen-print.docx
formula-screen-print.docx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You'll beed to amend your formula to something like
you will also need to change the line for teh February end date to handle leap years correctly i.e.
Local NumberVar CYear := Year(CurrentDate);
If {command.PR Period End Date} >= Date(CYear,01,01) and {command.PR Period End Date} <= Date(CYear,01,15) then 1 else
If {command.PR Period End Date} >= Date(CYear,01,16) and {command.PR Period End Date} <= Date(CYear,01,31) then 2 else
.
.
and so on for each line
you will also need to change the line for teh February end date to handle leap years correctly i.e.
If {command.PR Period End Date} >= Date(CYear,02,16) and {command.PR Period End Date} < Date(CYear,03,01) then 4 else
ASKER
This worked best for the scenario in the report. Thank you.
Isn't that the same as I posted in my earlier post ?
don't forget if you dont change the line that tests for end of feb the formula will fail for non leap years as ther isn't a 29th
don't forget if you dont change the line that tests for end of feb the formula will fail for non leap years as ther isn't a 29th