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?
garyjgsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jared_SCommented:
try Year(CurrentDate)
mlmccCommented:
Looks good

mlmcc
GJParkerCommented:
In full that would be

Date(Year(CurrentDate), 1, 1)
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

garyjgsAuthor Commented:
I have attached a screen print of what I am trying to accomplish with current year
formula-screen-print.docx
Jared_SCommented:
This will be the syntax for your if statement:

IF (Command.PR Period End Date) >= date(year(currentDate), 01, 01) and (Command.PR Period End Date) <= date(year(currentDate), 01, 15) then 1 else....

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GJParkerCommented:
You'll beed to amend your formula to something like

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

Open in new window



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

Open in new window

garyjgsAuthor Commented:
This worked best for the scenario in the report.  Thank you.
GJParkerCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.