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

Last Year

Status
Not open for further replies.

Dukester0122

IS-IT--Management
Mar 18, 2003
587
US
trying to create a formula that give me the previous year if I enter the current year parameter. example, if i enter 2007 as the current year then the previous year would be 2006.

i'm trying to use the datediff("yyyy", {year1},{year1} - 1) but i'm getting this error: A date is required here. Mainly because the year field is showing as 2,007.
 
If {year1} is a string, then the simplest is probably:

ToNumber({year1}) - 1

or using date conversions:

ToText(DateSerial (ToNumber({year1})-1, 1 ,1)), "yyyy")

If {year1} is a number then

{year1} - 1

or

ToText(DateSerial ({year1}-1, 1 ,1)), "yyyy")











 
That worked fine. Now that I got the year I need to show the amounts. the amount field is table.amount. can i use an if statement like

if {?year} = " " then table.amount
 
If I understand your question, you want to make a formula that references the parameter to return a numeric value (basically a field that is filtered for that specific year).

Yes, that is possible and your syntax looks right (though " " should be the year in question).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top