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

Need help with Leap Year - Impromptu 7.1.529 1

Status
Not open for further replies.

MzKitty

Programmer
Oct 28, 2003
254
US
Hi. We're using Impromptu 7.1.529 for our custom reports and I am trying to find some logic on how to determine if a year is a leap year. I'm just looking for an example of simple coding that divides the year by 4 and if there is no remainder, then it's a leap year and my Leap Year field is set to "Y". I know that this logic will not work in 300 years, but this report won't be around that long either. I've been up on Ultimates website looking thru the knowledge bases and I can't find anything that makes sense to me. Is there a simple function for this?

Cathy
 
Assuming you have a query item called 'YearNo' containing the year as an integer, you would need to create a new column (LeapYearIndicator) with logic something like
Code:
If ( mod([YearNo],4)=0 ) Then
  ('Y')
Else ('N')

Basically, the mod function returns the remainder of dividing the first argument by the second (dividing year by 4). If there is no remainder, then you have a leap year, otherwise you dont.

I don't have impromptu in front of me at the moment, so my syntax where I included the column may need to be checked, but this should do the trick.

J
 
JGirl,

The actual leap year rule is a little more complex. It involves looking at century years more closely. See This Link for more info.

The revised logic would be something like:

Code:
If ( mod([YearNo],4)=0 ) AND 
  NOT (mod([YearNo],100)=0 and mod([YearNo],400)<>0) Then
  ('Y')
Else ('N')

Regards,

Dave Griffin








[b]The Decision Support Group
Reporting Consulting with Cognos BI Tools
Magic with Data   [pc2]
Want good answers? Read FAQ401-2487 first!
[URL unfurl="true"]http://www.decisionsupportgroup.com[/URL][/b]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top