Perfectly fine except if you need to run this is a very large loop (such as batch processing 100 million records - although it only adds about 1.5 mins on my machine).
The modulo method takes (roughly) 54% the execution time of ICONV. This would be because of the extra processing ICONV has to do internally as well as the string concatenation and memory allocation from "Feb 29":YEAR Just something to keep in the back of the mind. * Date Conversion to detect if today is a leap year YEAR = OCONV(TODAY,"DY") TEST = ICONV("Feb 29":YEAR,"D") LEAP.YEAR = (STATUS() = 0) Vs * Leap year algorithm to detect if today is a leap year YEAR = OCONV(TODAY,"DY") IF MOD(YEAR,4) = 0 THEN IF MOD(YEAR, 100) = 0 THEN IF MOD(YEAR, 400) = 0 THEN LEAP.YEAR = 1 ELSE LEAP.YEAR = 0 END ELSE LEAP.YEAR = 1 END ELSE LEAP.YEAR = 0 -----Original Message----- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of David A. Green Sent: Wednesday, December 07, 2011 8:25 AM To: 'U2 Users List' Subject: Re: [U2] End of Month date routine YEAR = OCONV(PASS.DATE, "DY") TEST = ICONV("Feb 29 ":YEAR, "D") LEAP.YEAR = (STATUS() = 0) David A. Green (480) 813-1725 DAG Consulting -----Original Message----- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Daniel McGrath Sent: Tuesday, December 06, 2011 4:22 PM To: U2 Users List Subject: Re: [U2] End of Month date routine Leap years are a little more complex than MOD(YEAR,4) >From http://en.wikipedia.org/wiki/Leap_years#Algorithm if year modulo 4 is 0 then if year modulo 100 is 0 then if year modulo 400 is 0 then is_leap_year else not_leap_year else is_leap_year else not_leap_year -----Original Message----- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of John Hester Sent: Tuesday, December 06, 2011 4:16 PM To: U2 Users List Subject: Re: [U2] End of Month date routine Your method is also the way I've always done it, but an alternate method just came to mind: MONTH = OCONV(DATE, 'DM') YEAR = OCONV(DATE, 'D Y[Z4]') LEAP = MOD(YEAR, 4) = 0 MONTHS = '' MONTHS<1> = 31 MONTHS<2> = 28 + LEAP MONTHS<3> = 31 MONTHS<4> = 30 MONTHS<5> = 31 MONTHS<6> = 30 MONTHS<7> = 31 MONTHS<8> = 31 MONTHS<9> = 30 MONTHS<10> = 31 MONTHS<11> = 30 MONTHS<12> = 31 LAST.DAY = MONTHS<MONTH> Not very concise, but you can tell at a glance how many days your dealing with. -----Original Message----- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Holt, Jake Sent: Tuesday, December 06, 2011 2:34 PM To: U2 Users List Subject: Re: [U2] End of Month date routine Someone has probably already suggested one like this but I use: DATE = ICONV("2-11-11",'D') MONTH = OCONV(DATE,"DM") YEAR = OCONV(DATE,"DY") MONTH += 1 IF MONTH > 12 THEN MONTH = 1 YEAR += 1 END LAST.DAY = ICONV(MONTH:"/1/":YEAR,'D')-1 _______________________________________________ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users _______________________________________________ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users _______________________________________________ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users _______________________________________________ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users