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

Subtract CurrentDate year based on IF statement?

Status
Not open for further replies.

vbit

Programmer
Jul 31, 2001
47
US
Usuing CR 7 with SQL database.

I am trying to create a formula that displays the previous year if certain conditions are true.
For example:

X is number field

if X > month(CurrentDate) then ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November",
"December"] [X] + " " + ToText((CurrentDate -1),"yyyy")
else
["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November",
"December"] [X] + " " + ToText((CurrentDate),"yyyy")

The problem is that even though X is greater than month(CurrentDate) it still does not give me last year. It always shows the current year.

Thanks.
 
CurrentDate -1 subtracts one day, not one year.

Try Year(CurrentDate)-1 Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top