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

How do I check for 1st day of the year?

Status
Not open for further replies.

krpurcel

IS-IT--Management
Dec 1, 2003
77
US
I have reports that need to check what day of the year it is. On anything other than Jan 1 the reports will pull YTD data. If the date is Jan 1, I want the reports to pull PreviousFullYear. I have played around with DatePart but have not figured out how to do it.

Thanks!
 
Try a formula like this:

(
(
currentdate = date(year(currentdate),1,1) and
year({table.date}) = year(currentdate)-1
) or
(
currentdate <> date(year(currentdate),1,1) and
{table.date} in YearToDate
)
)

It would create a faster report if you first created a SQL expression {%year}:

{fn year(table.date)}

...and then used that instead of year({table.date}) in the formula above.

-LB
 
This is untested and feels incomplete, but something like this...

//check if today is january 1st

if (month(currentdate)=1 and day(currentdate)=1)
then {@PreviousFullYearFormula}
else {@YearToDateFormula}

where you supply the formulas.
 
Thanks guys! Your outstanding help is always appreciated!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top