Re: [U2] End of Month date routine

2011-12-08 Thread andy baum
: Re: [U2] End of Month date routine On UV the vlist would indicate yes (the complete expression is processed) . LEAP.YEAR = NOT(MOD(YEAR,4)) AND (NOT(MOD(YEAR,400)) OR MOD(YEAR,100)) 00062 : 0F6 mod            YEAR 4  = $R1 0006A : 10E not            $R1  = $R2 00070 : 0F6 mod            YEAR 400

Re: [U2] End of Month date routine

2011-12-07 Thread David A. Green
, 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

Re: [U2] End of Month date routine

2011-12-07 Thread David A. Green
of Month date routine Does someone have a routine that, no matter what day you run it, returns the End of Month Date ? (Assume the end of month date, is the calendar end of month date not some screwy business date) ___ U2-Users mailing list U2-Users

Re: [U2] End of Month date routine

2011-12-07 Thread Daniel McGrath
[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

Re: [U2] End of Month date routine

2011-12-07 Thread Wjhonson
@listserver.u2ug.org Sent: Wed, Dec 7, 2011 7:28 am Subject: Re: [U2] End of Month date routine Try this routine: SUBROUTINE RPT_DATES(OUT.DATES, IN.DATES, IN.DATE.TYPE, FLAG) * DAG_DATES - By David A. Green -- 1Jun05 * www.dagconsulting.com * * Calculate dates and date ranges

Re: [U2] End of Month date routine

2011-12-07 Thread Wjhonson
-Original Message- From: Daniel McGrath dmcgr...@rocketsoftware.com To: U2 Users List u2-users@listserver.u2ug.org Sent: Wed, Dec 7, 2011 8:02 am Subject: Re: [U2] End of Month date routine Perfectly fine except if you need to run this is a very large loop (such as atch processing 100

Re: [U2] End of Month date routine

2011-12-07 Thread David A. Green
Who wants to take each of the Leap Year calculations and put them into different subroutines and loop 100K times and see which one is faster using profiling? David A. Green (480) 813-1725 DAG Consulting ___ U2-Users mailing list

Re: [U2] End of Month date routine

2011-12-07 Thread Daniel McGrath
, 2011 10:29 AM To: u2-users@listserver.u2ug.org Subject: Re: [U2] End of Month date routine This algorithm is redundant and also fails to take into account the Boolean nature of the terms and thus adds extra unneeded op codes in the compare to 0 and compare to 1 steps. Below is the equivalent

Re: [U2] End of Month date routine

2011-12-07 Thread Wjhonson
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

Re: [U2] End of Month date routine

2011-12-07 Thread Wjhonson
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

Re: [U2] End of Month date routine

2011-12-07 Thread Martin Braid
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

Re: [U2] End of Month date routine

2011-12-07 Thread Daniel McGrath
-boun...@listserver.u2ug.org] On Behalf Of David A. Green Sent: Wednesday, December 07, 2011 10:48 AM To: 'U2 Users List' Subject: Re: [U2] End of Month date routine Who wants to take each of the Leap Year calculations and put them into different subroutines and loop 100K times and see which one

Re: [U2] End of Month date routine

2011-12-07 Thread Christine Callahan
FOR THE LAST DAY OF THE MONTH -Original Message- From: Marco Antonio Rojas Castro [mailto:marco_roja...@hotmail.com] Sent: Monday, December 05, 2011 3:49 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] End of Month date routine TODAY = DATE() EOM = TODAY - TODAYDD + 32 EOM = EOM - EOMDD

Re: [U2] End of Month date routine

2011-12-07 Thread David A. Green
- From: Daniel McGrath [mailto:dmcgr...@rocketsoftware.com] Sent: Wednesday, December 07, 2011 11:57 AM To: dgr...@dagconsulting.com; U2 Users List Subject: RE: [U2] End of Month date routine I added the code to PasteBin so as to not flood here: http://pastebin.com/JMyqhFud I did a few more than

Re: [U2] End of Month date routine

2011-12-07 Thread Wjhonson
...@rocketsoftware.com; 'U2 Users List' u2-users@listserver.u2ug.org Sent: Wed, Dec 7, 2011 12:23 pm Subject: Re: [U2] End of Month date routine Okay I took the fastest routine and made it into an $INSERT piece of code: YEAR = OCONV(THE.DATE, DY) F MOD(YEAR,4) THEN LEAP.YEAR = 0 ND ELSE IF MOD(YEAR

Re: [U2] End of Month date routine

2011-12-07 Thread Boydell, Stuart
And seeing how this thread is petering out how about this alternative: meDate = date() currentMonth = oconv(meDate,'dm') loop while oconv(meDate + 1,'dm') = curMonth do meDate += 1 repeat Personally I vote for Marco's solution, though it may need brackets or an

Re: [U2] End of Month date routine

2011-12-07 Thread andy baum
, Andy   From: Daniel McGrath dmcgr...@rocketsoftware.com To: dgr...@dagconsulting.com dgr...@dagconsulting.com; U2 Users List u2-users@listserver.u2ug.org Sent: Wednesday, 7 December 2011, 18:57 Subject: Re: [U2] End of Month date routine I added the code to PasteBin so as to not flood here

Re: [U2] End of Month date routine

2011-12-07 Thread andy baum
...@rocketsoftware.com To: dgr...@dagconsulting.com dgr...@dagconsulting.com; U2 Users List u2-users@listserver.u2ug.org Sent: Wednesday, 7 December 2011, 18:57 Subject: Re: [U2] End of Month date routine I added the code to PasteBin so as to not flood here: http://pastebin.com/JMyqhFud I did

Re: [U2] End of Month date routine

2011-12-07 Thread andy baum
To: 'Daniel McGrath' dmcgr...@rocketsoftware.com; 'U2 Users List' u2-users@listserver.u2ug.org Sent: Wednesday, 7 December 2011, 20:23 Subject: Re: [U2] End of Month date routine Okay I took the fastest routine and made it into an $INSERT piece of code: YEAR = OCONV(THE.DATE, DY) IF MOD(YEAR,4

Re: [U2] End of Month date routine

2011-12-07 Thread Wjhonson
Sent: Wed, Dec 7, 2011 7:25 pm Subject: Re: [U2] End of Month date routine Seem to have lost a bit of last reply which should have read Ran Dan's test code on latest Windows PE version of Universe and got :- 9.788 1.558 1.474 3.412 Tried NOT(MOD(YEAR,400)) OR(NOT(MOD(YEAR,4)) AND MOD(YEAR,100

Re: [U2] End of Month date routine

2011-12-07 Thread Boydell, Stuart
To: andyb...@yahoo.co.uk; u2-users@listserver.u2ug.org Subject: Re: [U2] End of Month date routine Why couldn't you say LEAP.YEAR = NOT(MOD(YEAR,4)) AND (NOT(MOD(YEAR,400)) OR MOD(YEAR,100)) Would the system process the whole line even on an initial finding of False ? -Original

Re: [U2] End of Month date routine

2011-12-07 Thread andy baum
December 2011 15:02 To: andyb...@yahoo.co.uk; u2-users@listserver.u2ug.org Subject: Re: [U2] End of Month date routine Why couldn't you say LEAP.YEAR = NOT(MOD(YEAR,4)) AND (NOT(MOD(YEAR,400)) OR MOD(YEAR,100)) Would the system process the whole line even on an initial finding of False

Re: [U2] End of Month date routine

2011-12-06 Thread Colin Alfke
That's better. It wasn't the ';' in the last one that caused the problem - especially with a generic routine - it was the reliance on the date format being m/d/y (which Dave's original noted). Not sure why you're trying so hard to compress the lines. This routine will easily fit in pretty much

Re: [U2] End of Month date routine

2011-12-06 Thread John Hatherill
List u2-users@listserver.u2ug.org Sent: Mon, Dec 5, 2011 5:00 pm Subject: Re: [U2] End of Month date routine Just for laughs, the following works with only a single date conversion, though will admit that it gets a little too obscure to be considered maintainable. dmittedly, there are probably

Re: [U2] End of Month date routine

2011-12-06 Thread Holt, Jake
...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of John Hatherill Sent: Tuesday, December 06, 2011 3:33 PM To: U2 Users List Subject: Re: [U2] End of Month date routine Tdate = OCONV(DATE(),D4-) mm1= Tdate[1,2]+1 1 = Tdate[7,4] if mm1 12 then mm1 = 01 1 += 1 end EDATE

Re: [U2] End of Month date routine

2011-12-06 Thread John Hester
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

Re: [U2] End of Month date routine

2011-12-06 Thread Daniel McGrath
: 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 = '' MONTHS1 = 31 MONTHS2 = 28 + LEAP MONTHS3 = 31 MONTHS4 = 30 MONTHS5 = 31 MONTHS6

Re: [U2] End of Month date routine

2011-12-06 Thread Wjhonson
: Tuesday, December 06, 2011 2:34 PM o: U2 Users List ubject: Re: [U2] End of Month date routine Someone has probably already suggested one like this but I use: DATE = ICONV(2-11-11,'D') ONTH = OCONV(DATE,DM) EAR = OCONV(DATE,DY) ONTH += 1 F MONTH 12 THEN ONTH = 1 EAR += 1 ND LAST.DAY = ICONV(MONTH:/1

Re: [U2] End of Month date routine

2011-12-06 Thread Keith Johnson [DATACOM]
Mr Castro's code wins. Pure elegance. Marco Antonio Rojas Castro - initials M.A.R.C. My uncle's name is Roy Owen Young - I tease him it's so he can remember it. Regards, Keith ___ U2-Users mailing list U2-Users@listserver.u2ug.org

Re: [U2] End of Month date routine

2011-12-05 Thread Dave Davis
- 1 ;* self-explanatory. -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson Sent: Monday, December 05, 2011 2:03 PM To: u2-users@listserver.u2ug.org Subject: [U2] End of Month date routine Does someone have

Re: [U2] End of Month date routine

2011-12-05 Thread Horacio Pellegrino
Using NEXT.MONTH and proper YEAR: ICONV(NEXT.MONTH:'/01/':YEAR)-1 will make the trick. HP On Mon, Dec 5, 2011 at 2:03 PM, Wjhonson wjhon...@aol.com wrote: Does someone have a routine that, no matter what day you run it, returns the End of Month Date ? (Assume the end of month date, is

Re: [U2] End of Month date routine

2011-12-05 Thread John Thompson
= FirstDayNextMonth - 1 ;* self-explanatory. -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto: u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson Sent: Monday, December 05, 2011 2:03 PM To: u2-users@listserver.u2ug.org Subject: [U2] End of Month date routine Does

Re: [U2] End of Month date routine

2011-12-05 Thread Wjhonson
is '01' -Original Message- From: John Thompson jthompson...@gmail.com To: U2 Users List u2-users@listserver.u2ug.org Sent: Mon, Dec 5, 2011 11:16 am Subject: Re: [U2] End of Month date routine This may not be the cleanest way, but, we use it here and it works. used ABORT, so some parent

Re: [U2] End of Month date routine

2011-12-05 Thread Charles_Shaffer
@listserver.u2ug.org, Date: 12/05/2011 01:03 PM Subject:[U2] End of Month date routine Sent by:u2-users-boun...@listserver.u2ug.org Does someone have a routine that, no matter what day you run it, returns the End of Month Date ? (Assume the end of month date, is the calendar end

Re: [U2] End of Month date routine

2011-12-05 Thread Dave Laansma
: Monday, December 05, 2011 2:22 PM To: U2 Users List Subject: Re: [U2] End of Month date routine Here's one I use. TODAY = OCONV(DATE(), D4/) MO = FIELD(TODAY, /, 1) YR = FIELD(TODAY, /, 3) MO += 1 IF MO 12 THEN MO = 1 YR += 1 END EOM = OCONV((ICONV(MO:/:1:YR) - 1), D4/) Charles Shaffer Senior

Re: [U2] End of Month date routine

2011-12-05 Thread Wjhonson
Thanks to everyone who responded This is with what I ended up MONTH = OCONV(DATE(),'DM') ; YEAR = OCONV(DATE(),'DY') IF MONTH = 12 THEN MONTH = 1 ; YEAR += 1 ELSE MONTH += 1 FIRST.OF.MONTH = ICONV(MONTH:/01/:YEAR,'D') END.OF.MONTH.DATE = FIRST.OF.MONTH-1 The only

Re: [U2] End of Month date routine

2011-12-05 Thread Wols Lists
On 05/12/11 19:03, Wjhonson wrote: Does someone have a routine that, no matter what day you run it, returns the End of Month Date ? (Assume the end of month date, is the calendar end of month date not some screwy business date) Hmmm... no-one seems to have done my approach ... TODAY =

Re: [U2] End of Month date routine

2011-12-05 Thread George Gallen
, December 05, 2011 3:05 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] End of Month date routine On 05/12/11 19:03, Wjhonson wrote: Does someone have a routine that, no matter what day you run it, returns the End of Month Date ? (Assume the end of month date, is the calendar end of month

Re: [U2] End of Month date routine

2011-12-05 Thread Wjhonson
or whatever but it's not working -Original Message- From: George Gallen ggal...@wyanokegroup.com To: U2 Users List u2-users@listserver.u2ug.org Sent: Mon, Dec 5, 2011 12:10 pm Subject: Re: [U2] End of Month date routine Haven't checked it, but what happens on 01/31 by adding 31, it should take

Re: [U2] End of Month date routine

2011-12-05 Thread Dave Laansma
...@listserver.u2ug.org] On Behalf Of George Gallen Sent: Monday, December 05, 2011 3:10 PM To: U2 Users List Subject: Re: [U2] End of Month date routine Haven't checked it, but what happens on 01/31 by adding 31, it should take you March, backing up Will give you 02/xx (28 or 29)? George

Re: [U2] End of Month date routine

2011-12-05 Thread George Gallen
...@listserver.u2ug.org] On Behalf Of Dave Laansma Sent: Monday, December 05, 2011 3:21 PM To: U2 Users List Subject: Re: [U2] End of Month date routine Ditto. Sincerely, David Laansma IT Manager Hubbard Supply Co. Direct: 810-342-7143 Office: 810-234-8681 Fax: 810-234-6142 www.hubbardsupply.com Delivering

Re: [U2] End of Month date routine

2011-12-05 Thread Robert Houben
But that would break the rhyme... :o -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of George Gallen Sent: December-05-11 12:26 PM To: U2 Users List Subject: Re: [U2] End of Month date routine Damn February...We need

Re: [U2] End of Month date routine

2011-12-05 Thread George Gallen
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Robert Houben Sent: Monday, December 05, 2011 3:30 PM To: U2 Users List Subject: Re: [U2] End of Month date routine But that would break the rhyme... :o -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun

Re: [U2] End of Month date routine

2011-12-05 Thread Marco Antonio Rojas Castro
TODAY = DATE() EOM = TODAY - TODAYDD + 32 EOM = EOM - EOMDD To: u2-users@listserver.u2ug.org From: wjhon...@aol.com Date: Mon, 5 Dec 2011 15:16:02 -0500 Subject: Re: [U2] End of Month date routine Doesn't work on my system Anthony. The This month o gives the month and year ok

Re: [U2] End of Month date routine

2011-12-05 Thread Colin Alfke
Doesn't work for me :( Tried on UD 7.1.6 and UD 6.0.12. It works for December, but I changed it to March and it gave me January 3rd. UniData does have a nice function LAST_DAY(x) for using in virtual attributes to return the last day of the month for the date passed to it. hth Colin Calgary,

Re: [U2] End of Month date routine

2011-12-05 Thread Dave Laansma
...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Marco Antonio Rojas Castro Sent: Monday, December 05, 2011 3:49 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] End of Month date routine TODAY = DATE() EOM = TODAY - TODAYDD + 32 EOM = EOM - EOMDD To: u2-users

Re: [U2] End of Month date routine

2011-12-05 Thread Marco Antonio Rojas Castro
) Date: Mon, 5 Dec 2011 15:52:40 -0500 From: dlaan...@hubbardsupply.com To: u2-users@listserver.u2ug.org Subject: Re: [U2] End of Month date routine No, this will fail on January 31st, every year. Sincerely, David Laansma IT Manager Hubbard Supply Co. Direct: 810-342-7143 Office: 810-234

Re: [U2] End of Month date routine

2011-12-05 Thread Rick Nuckolls
Behalf Of Wols Lists ent: Monday, December 05, 2011 3:05 PM o: u2-users@listserver.u2ug.org ubject: Re: [U2] End of Month date routine On 05/12/11 19:03, Wjhonson wrote: Does someone have a routine that, no matter what day you run it, returns the nd of Month Date ? (Assume the end of month

Re: [U2] End of Month date routine

2011-12-05 Thread Charlie Noah
Listu2-users@listserver.u2ug.org Sent: Mon, Dec 5, 2011 12:10 pm Subject: Re: [U2] End of Month date routine Haven't checked it, but what happens on 01/31 by adding 31, it should take you arch, backing up Will give you 02/xx (28 or 29)? George -Original Message- rom: u2-users-boun

Re: [U2] End of Month date routine

2011-12-05 Thread Israel, John R.
Of Charlie Noah Sent: Monday, December 05, 2011 4:27 PM To: U2 Users List Subject: Re: [U2] End of Month date routine I vote for the method (already posted) which will work every time on any MV system, any flavor, any emulation: find the first day of the next month and subtract 1. Messing around with adding

Re: [U2] End of Month date routine

2011-12-05 Thread Phil Walker
List' Subject: Re: [U2] End of Month date routine Agreed. That code is almost verbatim what I have used for 20+ years, and it has never failed me. John Israel Senior ERP Developer Dayton Superior Corporation 1125 Byers Rd Miamisburg, OH 45342 Office: 937-866-0711 x44380

Re: [U2] End of Month date routine

2011-12-05 Thread Phil Walker
Actually that will not work for a date near the end of the month. Was trying to be too smart -Original Message- From: Phil Walker Sent: Tuesday, 6 December 2011 10:47 a.m. To: 'U2 Users List' Subject: RE: [U2] End of Month date routine EOM = OCONV(ICONV(OCONV(@DATE+31,'D-YM

Re: [U2] End of Month date routine

2011-12-05 Thread Wjhonson
: [U2] End of Month date routine Doesn't work for me :( Tried on UD 7.1.6 and UD 6.0.12. It works for December, but I changed it to March and it gave me January 3rd. UniData does have a nice function LAST_DAY(x) for using in virtual ttributes to return the last day of the month for the date passed

Re: [U2] End of Month date routine

2011-12-05 Thread Wjhonson
: Marco Antonio Rojas Castro marco_roja...@hotmail.com To: u2-users u2-users@listserver.u2ug.org Sent: Mon, Dec 5, 2011 12:49 pm Subject: Re: [U2] End of Month date routine ODAY = DATE() OM = TODAY - TODAYDD + 32 OM = EOM - EOMDD To: u2-users@listserver.u2ug.org From: wjhon...@aol.com Date: Mon

Re: [U2] End of Month date routine

2011-12-05 Thread Wjhonson
wjhon...@aol.com To: u2-users u2-users@listserver.u2ug.org Sent: Mon, Dec 5, 2011 2:15 pm Subject: Re: [U2] End of Month date routine arco, this is absolutely brilliant. nd I reserve the use of the word brilliant, for code that truly transcends ormal space-time 'm not certain that the use of DD

Re: [U2] End of Month date routine

2011-12-05 Thread Wols Lists
...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wols Lists Sent: Monday, December 05, 2011 3:05 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] End of Month date routine On 05/12/11 19:03, Wjhonson wrote: Does someone have a routine that, no matter what day you

Re: [U2] End of Month date routine

2011-12-05 Thread Wols Lists
, Wol George -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wols Lists Sent: Monday, December 05, 2011 3:05 PM To: u2-users@listserver.u2ug.org Subject: Re: [U2] End of Month date routine On 05/12/11 19:03, Wjhonson

Re: [U2] End of Month date routine

2011-12-05 Thread Keith Johnson [DATACOM]
Dave Laansma took a more generic approach which does not require knowledge of the date format - hence I thought it preferable. My style would move the addition and subtraction around as below I assumed one would want the last day of the month for any called date otherwise uncomment line 2

Re: [U2] End of Month date routine

2011-12-05 Thread Rick Nuckolls
2:15 pm Subject: Re: [U2] End of Month date routine arco, this is absolutely brilliant. nd I reserve the use of the word brilliant, for code that truly transcends ormal space-time 'm not certain that the use of DD is vendor independent, but it could be made o, by merely using OCONV

Re: [U2] End of Month date routine

2011-12-05 Thread Wjhonson
Okay you win the prize for the longest method ;) -Original Message- From: Rick Nuckolls r...@lynden.com To: U2 Users List u2-users@listserver.u2ug.org Sent: Mon, Dec 5, 2011 5:00 pm Subject: Re: [U2] End of Month date routine Just for laughs, the following works with only