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)
0
mlmccCommented:
Looks good

mlmcc
0
GJParkerCommented:
In full that would be

Date(Year(CurrentDate), 1, 1)
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

garyjgsAuthor Commented:
I have attached a screen print of what I am trying to accomplish with current year
formula-screen-print.docx
0
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

0

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

0
garyjgsAuthor Commented:
This worked best for the scenario in the report.  Thank you.
0
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
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.