Oops, maybe all those Mods in my code are supposed to be... NOT(MOD... Just maybe
-----Original Message----- From: Daniel McGrath <dmcgr...@rocketsoftware.com> To: U2 Users List <u2-users@listserver.u2ug.org> Sent: Wed, Dec 7, 2011 10:22 am Subject: Re: [U2] End of Month date routine That doesn't give the correct results, although removing the comparisons with 0 ill improve it's performance - as you say. ----Original Message----- rom: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] n Behalf Of Wjhonson ent: Wednesday, December 07, 2011 10:29 AM o: u2-users@listserver.u2ug.org ubject: Re: [U2] End of Month date routine his algorithm is redundant and also fails to take into account the Boolean ature of the terms and thus adds extra unneeded op codes in the compare to 0 nd compare to 1 steps. Below is the equivalent BEGIN CASE CASE MOD(YEAR,400) ;LEAP.YEAR = TRUE CASE MOD(YEAR,100) ;LEAP.YEAR = FALSE CASE MOD(YEAR,4) ;LEAP.YEAR = TRUE ND CASE Leap year algorithm to detect if today is a leap year EAR = OCONV(TODAY,"DY") 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 D ELSE LEAP.YEAR = 0 -----Original Message----- rom: Daniel McGrath <dmcgr...@rocketsoftware.com> o: U2 Users List <u2-users@listserver.u2ug.org> ent: Wed, Dec 7, 2011 8:02 am ubject: Re: [U2] End of Month date routine erfectly fine except if you need to run this is a very large loop (such as atch rocessing 100 million records - although it only adds about 1.5 mins on y achine). he modulo method takes (roughly) 54% the execution time of ICONV. This would be cause of the extra processing ICONV has to do internally as well as the string ncatenation and memory allocation from "Feb 29":YEAR Just something to keep in he back of the mind. Date Conversion to detect if today is a leap year EAR = OCONV(TODAY,"DY") EST ICONV("Feb 29":YEAR,"D") EAP.YEAR = (STATUS() = 0) Vs Leap year algorithm to detect if today is a leap year EAR = OCONV(TODAY,"DY") 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 D ELSE LEAP.YEAR = 0 ----Original Message----- om: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] Behalf Of David A. Green nt: Wednesday, December 07, 2011 8:25 AM : 'U2 Users List' bject: Re: [U2] End of Month date routine YEAR = OCONV(PASS.DATE, "DY") EST = CONV("Feb 29 ":YEAR, "D") EAP.YEAR = (STATUS() = 0) David A. Green 80) 813-1725 G Consulting ----Original Message----- om: u2-users-boun...@listserver.u2ug.org ailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Daniel McGrath nt: Tuesday, December 06, 2011 4:22 PM : U2 Users List bject: Re: [U2] End of Month date routine Leap years are a little more complex han MOD(YEAR,4) >From http://en.wikipedia.org/wiki/Leap_years#Algorithm f 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 se not_leap_year -----Original Message----- om: u2-users-boun...@listserver.u2ug.org ailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of John Hester nt: Tuesday, December 06, 2011 4:16 PM : U2 Users List bject: Re: [U2] End of Month date routine Your method is also the way I've lways done it, but an alternate method just ame to mind: ONTH = OCONV(DATE, 'DM') AR = OCONV(DATE, 'D Y[Z4]') AP = MOD(YEAR, 4) = 0 NTHS = '' NTHS<1> = 31 NTHS<2> = 28 + LEAP NTHS<3> = 31 NTHS<4> = 30 NTHS<5> = 31 NTHS<6> = 30 NTHS<7> = 31 NTHS<8> = 31 NTHS<9> = 30 NTHS<10> = 31 NTHS<11> = 30 NTHS<12> = 31 ST.DAY = MONTHS<MONTH> ot very concise, but you can tell at a glance how many days your dealing with. ---Original Message----- om: u2-users-boun...@listserver.u2ug.org ailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Holt, Jake nt: Tuesday, December 06, 2011 2:34 PM : U2 Users List bject: Re: [U2] End of Month date routine Someone has probably already uggested one like this but I use: ATE = ICONV("2-11-11",'D') NTH = OCONV(DATE,"DM") AR = OCONV(DATE,"DY") NTH += 1 MONTH > 12 THEN NTH = 1 AR += 1 D AST.DAY = ICONV(MONTH:"/1/":YEAR,'D')-1 _______________________________________________ -Users mailing list -us...@listserver.u2ug.org tp://listserver.u2ug.org/mailman/listinfo/u2-users _____________________________________________ -Users mailing list -us...@listserver.u2ug.org tp://listserver.u2ug.org/mailman/listinfo/u2-users ______________________________________________ -Users mailing list -us...@listserver.u2ug.org tp://listserver.u2ug.org/mailman/listinfo/u2-users _____________________________________________ -Users mailing list -us...@listserver.u2ug.org tp://listserver.u2ug.org/mailman/listinfo/u2-users _______________________________________________ 2-Users mailing list 2-us...@listserver.u2ug.org ttp://listserver.u2ug.org/mailman/listinfo/u2-users ______________________________________________ 2-Users mailing list 2-us...@listserver.u2ug.org ttp://listserver.u2ug.org/mailman/listinfo/u2-users _______________________________________________ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users