LEAP.YEAR needs to be FALSE at the start -----Original Message----- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson Sent: 07 December 2011 18:49 To: u2-users@listserver.u2ug.org Subject: Re: [U2] End of Month date routine
Because ? -----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 Click https://www.mailcontrol.com/sr/wQw0zmjPoHdJTZGyOCrrhg== 2432FJ4IwoFd5vazAvF4FgIQMJmn0icupbw2vPhlBpHvw== to report this email as spam. -------------------------------------------------------- Epicor Software (UK) is a limited company registered in England & Wales. Registration Number: 2338274. Registered Office: 6th Floor, One London Wall, London EC2Y 5EB This e-mail is for the use of the intended recipient(s) only. If you have received this e-mail in error, please notify the sender immediately and then delete it. If you are not the intended recipient, you must not use, disclose or distribute this e-mail without the author's prior permission. We have taken precautions to minimize the risk of transmitting software viruses, but we advise you to carry out your own virus checks on any attachment to this message. We cannot accept liability for any loss or damage caused by software viruses. Any views and/or opinions expressed in this e-mail are of the author only and do not represent the views of Epicor Software (UK) Limited or any other company within its group. This message has been scanned for malware by Websense. www.websense.com _______________________________________________ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users