Re: [U2] End of Month date routine

2011-12-08 Thread andy baum
Scratch that, should read things more carefully, obviously 2 hours sleep is not 
enough.


Cheers,

Andy




 From: andy baum andyb...@yahoo.co.uk
To: U2 Users List u2-users@listserver.u2ug.org 
Sent: Thursday, 8 December 2011, 7:52
Subject: Re: [U2] End of Month date routine
 
Stuart,


You are getting the performance from the case statement by having  
     
      case mod(YEAR,4) ; LEAP.YEAR = @false 


first, unfortunately when using case, the order is important and this needs to 
go just before the case @true. In your example


     
case mod(YEAR,400); LEAP.YEAR = @false 

will never be happen as it will already have been picked up by the previous case

Cheers,
Andy




From: Boydell, Stuart stuart.boyd...@spotless.com.au
To: U2 Users List u2-users@listserver.u2ug.org 
Sent: Thursday, 8 December 2011, 6:44
Subject: 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  = $R3
00078 : 10E not            $R3  = $R4
0007E : 0F6 mod            YEAR 100  = $R5
00086 : 122 or             $R4 $R5  = $R6
0008E : 008 and            $R2 $R6  = LEAP.YEAR
00096 : 190 stop

I get minuscually better results using a case statement:

YEAR = oconv(THE.DATE, 'dy')
begin case
case mod(YEAR,4) ; LEAP.YEAR = @false
case mod(YEAR,100); LEAP.YEAR = @true
case mod(YEAR,400); LEAP.YEAR = @false
case @true ; LEAP.YEAR = @true
end case


-Original Message-
From: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson
Sent: Thursday, 8 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 ?









-Original Message-
From: andy baum andyb...@yahoo.co.uk
To: U2 Users List u2-users@listserver.u2ug.org
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))) which took 2.181 
seconds but the fastest I could get was

LEAP.YEAR = NOT(MOD(YEAR,4))
IF LEAP.YEAR THEN
           LEAP.YEAR = (NOT(MOD(YEAR,400)) OR MOD(YEAR,100)) END

which took 1.423 seconds

Got the same trend, although different timings on our Solaris 10 box running 
Universe 10.3.6

Cheers,
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: 
http://pastebin.com/JMyqhFud

I did a few more than 100K and I cut the OCONV step out from all of them. I 
took the liberty to adjust Will's version to return correct results. The 
results I got, in order, was:

16.872
2.804
2.384
5.561

So, if you have a need to account for your milliseconds, the slightly optimized 
Wikipedia algorithm seems to be the fastest.

Interested to see if there are any better? (Or if I made any mistakes...)

Regards,
Dan

-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 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 is faster using 
profiling?

David A. Green
(480) 813-1725
DAG Consulting

___
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



___
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

Re: [U2] End of Month date routine

2011-12-07 Thread David A. Green
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 = ''
MONTHS1 = 31
MONTHS2 = 28 + LEAP
MONTHS3 = 31
MONTHS4 = 30
MONTHS5 = 31
MONTHS6 = 30
MONTHS7 = 31
MONTHS8 = 31
MONTHS9 = 30
MONTHS10 = 31
MONTHS11 = 30
MONTHS12 = 31
LAST.DAY = MONTHSMONTH

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


Re: [U2] End of Month date routine

2011-12-07 Thread David A. Green
 IN.DATE.PTR = 1 ; GOSUB CALC.NUMBER.OF.MONTHS.FIRST.PASS
CASE IN.DATE.PTR = 2 ; GOSUB CALC.NUMBER.OF.MONTHS.SECOND.PASS
CASE 1   ; MSG = Too many dates given ; GOSUB
ABORT.MSG
 END CASE
 OUT.DATE.PTR = 1
 RETURN
 !
CALC.NUMBER.OF.MONTHS.FIRST.PASS:
 FIRST.DATE  = IN.DATE
 FIRST.MONTH = IN.MONTH
 FIRST.YEAR  = IN.YEAR
 RETURN
 !
CALC.NUMBER.OF.MONTHS.SECOND.PASS:
 SECOND.DATE = IN.DATE
 IF SECOND.DATE  FIRST.DATE THEN  ;* In case dates are flipped flopped.
SECOND.MONTH = FIRST.MONTH
SECOND.YEAR  = FIRST.YEAR
FIRST.MONTH  = IN.MONTH
FIRST.YEAR   = IN.YEAR
IN.MONTH = SECOND.MONTH
IN.YEAR  = SECOND.YEAR
 END
 OUT.DATE = 1
 LOOP UNTIL IN.MONTH:IN.YEAR = FIRST.MONTH:FIRST.YEAR DO
OUT.DATE += 1
GOSUB DEC.IN.MONTH
 REPEAT
 RETURN
 !
DO.YEAR.ARRAY.OF.MONTHS:
 GOSUB DO.FIRST.DAY.OF.YEAR
 IN.MONTH = OCONV(OUT.DATE, DM)
 IN.YEAR  = OCONV(OUT.DATE, DY)
 IN.DAY   = OCONV(OUT.DATE, DD)
 OUT.DATES1, 1 = OUT.DATE
 FOR DATE.PTR = 2 TO 12
GOSUB INC.IN.MONTH
GOSUB DO.FIRST.DAY.OF.MONTH
OUT.DATES1, DATE.PTR = OUT.DATE
 NEXT DATE.PTR
 RETURN
 !
DO.YEAR.ARRAY.OF.QUARTERS:
 GOSUB DO.FIRST.DAY.OF.YEAR
 IN.MONTH = OCONV(OUT.DATE, DM)
 IN.YEAR  = OCONV(OUT.DATE, DY)
 IN.DAY   = OCONV(OUT.DATE, DD)
 OUT.DATES1, 1 = OUT.DATE
 FOR DATE.PTR = 2 TO 12
GOSUB INC.IN.MONTH
GOSUB DO.FIRST.DAY.OF.MONTH
BEGIN CASE
   CASE DATE.PTR =  4; OUT.DATES1, -1 = OUT.DATE
   CASE DATE.PTR =  7; OUT.DATES1, -1 = OUT.DATE
   CASE DATE.PTR = 10; OUT.DATES1, -1 = OUT.DATE
END CASE
 NEXT DATE.PTR
 RETURN
 !
DO.TODAY:
 OUT.DATE = @DATE
 RETURN
 !
DO.YEAR:
 OUT.DATE = IN.YEAR
 RETURN
 !
INIT.DATE:
 IN.DATE.PTR += 1
 OUT.DATE.PTR = IN.DATE.PTR
 IN.DAY   = OCONV(IN.DATE, DD)
 IF STATUS() THEN
MSG = Invalid Input Date #:IN.DATE.PTR: :DQUOTE(IN.DATE)
GOSUB ABORT.MSG
 END ELSE
IN.MONTH  = OCONV(IN.DATE, DM)
IN.YEAR   = OCONV(IN.DATE, DY)
 END
 RETURN
 !
INIT.SUB:
 ABORT.FLAG   = FALSE
 IF UNASSIGNED(FLAG) THEN FLAG = 
 FUDGE.DAYS   = (UPCASE(FLAG) EQ FUDGE) * 7
 FLAG = 
 OUT.DATES= 
 OUT.DATE = 
 OUT.DATE.PTR = 0
 IN.DATE.PTR  = 0
 *
 ** Validate/Set Date Format - Month/Day/Year or Day/Month/Year
 *
 INT.DATE.FORMAT = SYSTEM(36)
 BEGIN CASE
CASE INT.DATE.FORMAT = 0 ; DATE.FORMAT = MD
CASE INT.DATE.FORMAT = 1 ; DATE.FORMAT = DM
CASE 1   ; GOSUB UNSUPPORTED.DATE.FORMAT
 END CASE
 RETURN
 !
UNSUPPORTED.DATE.FORMAT:
 MSG = Unsupported Date Format :DQUOTE(SYSTEM(36))
 GOSUB ABORT.MSG
 RETURN
 !
INVALID.TYPE:
 MSG = Invalid Date Type :DQUOTE(IN.DATE.TYPE)
 GOSUB ABORT.MSG
 RETURN
 !
ABORT.MSG:
 FLAG-1   = MSG
 ABORT.FLAG = TRUE
 OUT.DATE   = 
 RETURN
 !
 END

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 Wjhonson
Sent: Monday, December 05, 2011 12:03 PM
To: u2-users@listserver.u2ug.org
Subject: [U2] End 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@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


Re: [U2] End of Month date routine

2011-12-07 Thread Daniel McGrath
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 = ''
MONTHS1 = 31
MONTHS2 = 28 + LEAP
MONTHS3 = 31
MONTHS4 = 30
MONTHS5 = 31
MONTHS6 = 30
MONTHS7 = 31
MONTHS8 = 31
MONTHS9 = 30
MONTHS10 = 31
MONTHS11 = 30
MONTHS12 = 31
LAST.DAY = MONTHSMONTH

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


Re: [U2] End of Month date routine

2011-12-07 Thread Wjhonson

Ok you win the Subroutines Gone Wild prize
But David what about ON...GOSUB ?
A very powerful and very little used operation which would turn your case into 
a long long line



-Original Message-
From: David A. Green dgr...@dagconsulting.com
To: 'U2 Users List' u2-users@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
*
** Inputs:
*IN.DATES  - Single or Multivalued List of Dates as reference
ates
*IN.DATE.TYPE  - Type of Date to Calculate, Supported Types are:
*  FIRST.DAY.OF.MONTH
*  LAST.DAY.OF.MONTH
*  LAST.DAY.OF.PREVIOUS.MONTH
*  LAST.DAY.OF.NEXT.MONTH
*  FIRST.DAY.OF.YEAR
*  LAST.DAY.OF.YEAR
*  CALC.NUMBER.OF.MONTHS
*  YEAR.ARRAY.OF.MONTHS
*  YEAR.ARRAY.OF.QUARTERS
*  TODAY
*  FIRST.DAY.OF.PREVIOUS.MONTH
*  FIRST.DAY.OF.NEXT.MONTH
*  YEAR
*FLAG  - Flag can be used to Fudge a date or Exact dates
*  FUDGE - Will subtract 7 days from the IN.DATES
nd return
*  a First or Last Date based on the fudged
N.DATES.
*  EXACT - Will use IN.DATES as passed to
ubroutine. (default)
*
** Outputs:
*OUT.DATES - Calculated Dates based on Input Parameters
*FLAG  - Set with error messages if any
*
EQUATE TRUE TO 1, FALSE TO 0
*
GOSUB INIT.SUB
*
IN.DATES   = IN.DATES ;* Reset Remove Pointer (Necessary because
ariable gets set in another program)
MORE.DATES = (IN.DATES # )
LOOP WHILE MORE.DATES AND NOT(ABORT.FLAG) DO
   IN.DATE = REMOVE(IN.DATES, MORE.DATES) - FUDGE.DAYS
   GOSUB INIT.DATE
   IF NOT(ABORT.FLAG) THEN
  BEGIN CASE
 CASE IN.DATE.TYPE = FIRST.DAY.OF.MONTH  ; GOSUB
O.FIRST.DAY.OF.MONTH
 CASE IN.DATE.TYPE = LAST.DAY.OF.MONTH   ; GOSUB
O.LAST.DAY.OF.MONTH
 CASE IN.DATE.TYPE = LAST.DAY.OF.PREVIOUS.MONTH  ; GOSUB
O.LAST.DAY.OF.PREVIOUS.MONTH
 CASE IN.DATE.TYPE = LAST.DAY.OF.NEXT.MONTH  ; GOSUB
O.LAST.DAY.OF.NEXT.MONTH
 CASE IN.DATE.TYPE = FIRST.DAY.OF.YEAR   ; GOSUB
O.FIRST.DAY.OF.YEAR
 CASE IN.DATE.TYPE = LAST.DAY.OF.YEAR; GOSUB
O.LAST.DAY.OF.YEAR
 CASE IN.DATE.TYPE = CALC.NUMBER.OF.MONTHS   ; GOSUB
O.CALC.NUMBER.OF.MONTHS
 CASE IN.DATE.TYPE = YEAR.ARRAY.OF.MONTHS; GOSUB
O.YEAR.ARRAY.OF.MONTHS
 CASE IN.DATE.TYPE = YEAR.ARRAY.OF.QUARTERS  ; GOSUB
O.YEAR.ARRAY.OF.QUARTERS
 CASE IN.DATE.TYPE = TODAY   ; GOSUB
O.TODAY
 CASE IN.DATE.TYPE = FIRST.DAY.OF.PREVIOUS.MONTH ; GOSUB
O.FIRST.DAY.OF.PREVIOUS.MONTH
 CASE IN.DATE.TYPE = FIRST.DAY.OF.NEXT.MONTH ; GOSUB
O.FIRST.DAY.OF.NEXT.MONTH
 CASE IN.DATE.TYPE = YEAR; GOSUB
O.YEAR
 CASE 1; GOSUB
NVALID.TYPE
  END CASE
  BEGIN CASE
 CASE IN.DATE.TYPE = YEAR.ARRAY.OF.MONTHS
 CASE IN.DATE.TYPE = YEAR.ARRAY.OF.QUARTERS
 CASE 1; OUT.DATES1, OUT.DATE.PTR = OUT.DATE
  END CASE
   END
REPEAT
*
RETURN
!
O.FIRST.DAY.OF.MONTH:
BEGIN CASE
   CASE DATE.FORMAT = MD ; THE.DATE = IN.MONTH:/01/:IN.YEAR
   CASE DATE.FORMAT = DM ; THE.DATE = 01/:IN.MONTH:/:IN.YEAR
END CASE
OUT.DATE = ICONV(THE.DATE, D)
RETURN
!
O.FIRST.DAY.OF.PREVIOUS.MONTH:
GOSUB DEC.IN.MONTH
BEGIN CASE
   CASE DATE.FORMAT = MD ; THE.DATE = IN.MONTH:/01/:IN.YEAR
   CASE DATE.FORMAT = DM ; THE.DATE = 01/:IN.MONTH:/:IN.YEAR
END CASE
OUT.DATE = ICONV(THE.DATE, D)
RETURN
!
O.FIRST.DAY.OF.NEXT.MONTH:
GOSUB INC.IN.MONTH
BEGIN CASE
   CASE DATE.FORMAT = MD ; THE.DATE = IN.MONTH:/01/:IN.YEAR
   CASE DATE.FORMAT = DM ; THE.DATE = 01/:IN.MONTH:/:IN.YEAR
END CASE
OUT.DATE = ICONV(THE.DATE, D)
RETURN
!
O.LAST.DAY.OF.MONTH:
GOSUB INC.IN.MONTH
GOSUB DO.FIRST.DAY.OF.MONTH
OUT.DATE -= 1
RETURN
!
O.LAST.DAY.OF.PREVIOUS.MONTH:
GOSUB DO.FIRST.DAY.OF.MONTH
OUT.DATE -= 1
RETURN
!
O.LAST.DAY.OF.NEXT.MONTH:
GOSUB INC.IN.MONTH
GOSUB DO.LAST.DAY.OF.MONTH
RETURN
!
NC.IN.MONTH:
IN.MONTH += 1
IF IN.MONTH  12 THEN IN.MONTH = 1 ; IN.YEAR += 1
RETURN
!
EC.IN.MONTH:
IN.MONTH -= 1
IF IN.MONTH  1 THEN IN.MONTH = 12 ; IN.YEAR -= 1

Re: [U2] End of Month date routine

2011-12-07 Thread Wjhonson

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

BEGIN CASE
   CASE MOD(YEAR,400) ;LEAP.YEAR = TRUE
   CASE MOD(YEAR,100) ;LEAP.YEAR = FALSE
   CASE MOD(YEAR,4) ;LEAP.YEAR = TRUE
END CASE


* Leap year algorithm to detect if today is a leap year
EAR = OCONV(TODAY,DY)
F 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
ND ELSE LEAP.YEAR = 0





-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 million records - although it only adds about 1.5 mins on 
y machine).
The modulo method takes (roughly) 54% the execution time of ICONV. This would 
be 
ecause of the extra processing ICONV has to do internally as well as the string 
oncatenation 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
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)
F 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
ND ELSE LEAP.YEAR = 0
-Original Message-
rom: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] 
n Behalf Of David A. Green
ent: Wednesday, December 07, 2011 8:25 AM
o: 'U2 Users List'
ubject: Re: [U2] End of Month date routine
YEAR = OCONV(PASS.DATE, DY)
EST = ICONV(Feb 29 :YEAR, D)
EAP.YEAR = (STATUS() = 0)
David A. Green
480) 813-1725
AG Consulting
-Original Message-
rom: u2-users-boun...@listserver.u2ug.org
mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Daniel McGrath
ent: Tuesday, December 06, 2011 4:22 PM
o: U2 Users List
ubject: 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
lse not_leap_year

-Original Message-
rom: u2-users-boun...@listserver.u2ug.org
mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of John Hester
ent: Tuesday, December 06, 2011 4:16 PM
o: U2 Users List
ubject: Re: [U2] End of Month date routine
Your method is also the way I've always done it, but an alternate method just 
ame to mind:
MONTH = OCONV(DATE, 'DM')
EAR = OCONV(DATE, 'D Y[Z4]')
EAP = MOD(YEAR, 4) = 0
ONTHS = ''
ONTHS1 = 31
ONTHS2 = 28 + LEAP
ONTHS3 = 31
ONTHS4 = 30
ONTHS5 = 31
ONTHS6 = 30
ONTHS7 = 31
ONTHS8 = 31
ONTHS9 = 30
ONTHS10 = 31
ONTHS11 = 30
ONTHS12 = 31
AST.DAY = MONTHSMONTH
Not very concise, but you can tell at a glance how many days your dealing with. 
 

Original Message-
rom: u2-users-boun...@listserver.u2ug.org
mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Holt, Jake
ent: 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/:YEAR,'D')-1 
___
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
___
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


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
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] End of Month date routine

2011-12-07 Thread Daniel McGrath
That doesn't give the correct results, although removing the comparisons with 0 
will improve it's performance - as you say.


-Original Message-
From: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson
Sent: Wednesday, December 07, 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

BEGIN CASE
   CASE MOD(YEAR,400) ;LEAP.YEAR = TRUE
   CASE MOD(YEAR,100) ;LEAP.YEAR = FALSE
   CASE MOD(YEAR,4) ;LEAP.YEAR = TRUE
END CASE


* Leap year algorithm to detect if today is a leap year EAR = OCONV(TODAY,DY) 
F 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
ND ELSE LEAP.YEAR = 0





-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 million records - although it only adds about 1.5 mins on y 
machine).
The modulo method takes (roughly) 54% the execution time of ICONV. This would 
be ecause of the extra processing ICONV has to do internally as well as the 
string oncatenation 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 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) 
F 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
ND ELSE LEAP.YEAR = 0
-Original Message-
rom: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org]
n Behalf Of David A. Green
ent: Wednesday, December 07, 2011 8:25 AM
o: 'U2 Users List'
ubject: Re: [U2] End of Month date routine YEAR = OCONV(PASS.DATE, DY) EST = 
ICONV(Feb 29 :YEAR, D) EAP.YEAR = (STATUS() = 0) David A. Green
480) 813-1725
AG Consulting
-Original Message-
rom: u2-users-boun...@listserver.u2ug.org
mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Daniel McGrath
ent: Tuesday, December 06, 2011 4:22 PM
o: U2 Users List
ubject: 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
lse not_leap_year

-Original Message-
rom: u2-users-boun...@listserver.u2ug.org
mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of John Hester
ent: Tuesday, December 06, 2011 4:16 PM
o: U2 Users List
ubject: Re: [U2] End of Month date routine Your method is also the way I've 
always done it, but an alternate method just ame to mind:
MONTH = OCONV(DATE, 'DM')
EAR = OCONV(DATE, 'D Y[Z4]')
EAP = MOD(YEAR, 4) = 0
ONTHS = ''
ONTHS1 = 31
ONTHS2 = 28 + LEAP
ONTHS3 = 31
ONTHS4 = 30
ONTHS5 = 31
ONTHS6 = 30
ONTHS7 = 31
ONTHS8 = 31
ONTHS9 = 30
ONTHS10 = 31
ONTHS11 = 30
ONTHS12 = 31
AST.DAY = MONTHSMONTH
Not very concise, but you can tell at a glance how many days your dealing with. 
 

Original Message-
rom: u2-users-boun...@listserver.u2ug.org
mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Holt, Jake
ent: 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/:YEAR,'D')-1 
___
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
___
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
___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org

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 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 = ''
NTHS1 = 31
NTHS2 = 28 + LEAP
NTHS3 = 31
NTHS4 = 30
NTHS5 = 31
NTHS6 = 30
NTHS7 = 31
NTHS8 = 31
NTHS9 = 30
NTHS10 = 31
NTHS11 = 30
NTHS12 = 31
ST.DAY = MONTHSMONTH
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

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


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 = ''
NTHS1 = 31
NTHS2 = 28 + LEAP
NTHS3 = 31
NTHS4 = 30
NTHS5 = 31
NTHS6 = 30
NTHS7 = 31
NTHS8 = 31
NTHS9 = 30
NTHS10 = 31
NTHS11 = 30
NTHS12 = 31
ST.DAY = MONTHSMONTH
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

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 ?



-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 = ''
NTHS1 = 31
NTHS2 = 28 + LEAP
NTHS3 = 31
NTHS4 = 30
NTHS5 = 31
NTHS6 = 30
NTHS7 = 31
NTHS8 = 31
NTHS9 = 30
NTHS10 = 31
NTHS11 = 30
NTHS12 = 31
ST.DAY = MONTHSMONTH
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

Re: [U2] End of Month date routine

2011-12-07 Thread Daniel McGrath
I added the code to PasteBin so as to not flood here: 
http://pastebin.com/JMyqhFud

I did a few more than 100K and I cut the OCONV step out from all of them. I 
took the liberty to adjust Will's version to return correct results. The 
results I got, in order, was:

16.872
2.804
2.384
5.561

So, if you have a need to account for your milliseconds, the slightly optimized 
Wikipedia algorithm seems to be the fastest.

Interested to see if there are any better? (Or if I made any mistakes...)

Regards,
Dan

-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 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 is faster using 
profiling?

David A. Green
(480) 813-1725
DAG Consulting

___
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


Re: [U2] End of Month date routine

2011-12-07 Thread Christine Callahan
Try:
TODAY=DATE()
THIS.MO=OCONV(TODAY,'DM')
THIS.YR=OCONV(TODAY,'DY')
IF THIS.MO+1 LE 12 THEN
*SAME YEAR
   FIRST.OF.MONTH=THIS.MONTH+1:-:01:THIS.YR
END ELSE
*NEXT YEAR
   FIRST.OF.MONTH='01-01-':THIS.YR+1
END
END.OF.MONTH=ICONV(FIRST.MONTH,'D')-1
**END.OF.MONTH IS THE INTERNAL DATE 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

 

 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
 but the attempt to iconv that sets it to zero, it doesn't pad the 01
into it or something
 so i just get 31 at that point.
 
 I think you were expecting that it would take 12 2011 and make it into
12 01 2011 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
you 
 arch, backing up
 Will give you 02/xx (28 or 29)?
 George
 -Original Message-
 rom: u2-users-boun...@listserver.u2ug.org
[mailto:u2-users-boun...@listserver.u2ug.org] 
 n 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 date, is the calendar end of month date not some 
 crewy business date)
 Hmmm... no-one seems to have done my approach ...
 TODAY = @DATE
 HIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off
 EXT.MONTH.I = ICONV( THIS.MONTH.O, D) + 31 ;* random day next month
 EXT.MONTH.O = OCONV( NEXT.MONTH.I, DMY) ;* strip day off
 AST.DAY.I = ICONV( NEXT.MONTH.O, D) - 1 ;* subract one day
 If you don't have a day in your i/oconv it defaults to 1, so the logic 
 orks. Unfortunately you can't combine the first three lines because 
 here's no number you can pick that will guarantee to land you in next 
 onth whatever today's date :-(
 Cheers,
 ol
 __
 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
  

___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] End of Month date routine

2011-12-07 Thread David A. Green
Okay I took the fastest routine and made it into an $INSERT piece of code:

YEAR = OCONV(THE.DATE, DY)
IF MOD(YEAR,4) THEN
   LEAP.YEAR = 0
END ELSE
   IF MOD(YEAR, 100) THEN
  LEAP.YEAR = 1
   END ELSE 
  IF MOD(YEAR, 400) THEN LEAP.YEAR = 0 ELSE LEAP.YEAR = 1
   END
END

Then created a Function like:
FUNCTION LEAP.YEAR.FUN( THE.DATE )
$INSERT LEAP.YEAR.INS
RETURN LEAP.YEAR

And a Subroutine like:
SUBROUTINE LEAP.YEAR.SUB( LEAP.YEAR, THE.DATE )
$INSERT LEAP.YEAR.INS
RETURN

Then modified Daniel's test program like:
DEFFUN LEAP.YEAR.FUN( THE.DATE )
EQU LC TO 1000
*
ST = TIME()
FOR THE.DATE = 1 TO LC
   LEAP.YEAR = LEAP.YEAR.FUN( THE.DATE )
NEXT THE.DATE
TS = TIME()
CRT TS - ST
*
*
ST = TIME()
FOR THE.DATE = 1 TO LC
  CALL LEAP.YEAR.SUB( LEAP.YEAR, THE.DATE )
NEXT THE.DATE
TS = TIME()
CRT TS - ST
*
ST = TIME()
FOR THE.DATE = 1 TO LC
  $INSERT LEAP.YEAR.INS
NEXT THE.DATE
TS = TIME()
CRT TS - ST
*
END

The speed results:
Function 24 seconds
Subroutine 21 seconds
Insert 11 seconds

Not surprising results given what we know about these three methods.
Although the function method did get better since the last time I've test
it.

UD 6.1

Other systems will vary.

But this is a good example of working together to enhance the U2 products,
now we all have the same Leap Year calculation and those that were using the
MOD(YEAR, 4) method should now use this method everywhere as to avoid data
corruption.

David A. Green
(480) 813-1725
DAG Consulting


-Original Message-
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 100K and I cut the OCONV step out from all of them. I
took the liberty to adjust Will's version to return correct results. The
results I got, in order, was:

16.872
2.804
2.384
5.561

So, if you have a need to account for your milliseconds, the slightly
optimized Wikipedia algorithm seems to be the fastest.

Interested to see if there are any better? (Or if I made any mistakes...)

Regards,
Dan

-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 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 is faster using
profiling?

David A. Green
(480) 813-1725
DAG Consulting

___
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


Re: [U2] End of Month date routine

2011-12-07 Thread Wjhonson



YEAR = OCONV(THE.DATE, DY)
EGIN CASE
CASE MOD(YEAR,4); LEAP.YEAR = FALSE
ASE MOD(YEAR, 100); LEAP.YEAR = TRUE
ASE MOD(YEAR, 400); LEAP.YEAR = FALSE
CASE 1; LEAP.YEAR = TRUE
ND CASE





-Original Message-
From: David A. Green dgr...@dagconsulting.com
To: 'Daniel McGrath' dmcgr...@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, 100) THEN
 LEAP.YEAR = 1
  END ELSE 
 IF MOD(YEAR, 400) THEN LEAP.YEAR = 0 ELSE LEAP.YEAR = 1
  END
ND
Then created a Function like:
UNCTION LEAP.YEAR.FUN( THE.DATE )
INSERT LEAP.YEAR.INS
ETURN LEAP.YEAR
And a Subroutine like:
UBROUTINE LEAP.YEAR.SUB( LEAP.YEAR, THE.DATE )
INSERT LEAP.YEAR.INS
ETURN
Then modified Daniel's test program like:
EFFUN LEAP.YEAR.FUN( THE.DATE )
QU LC TO 1000

T = TIME()
OR THE.DATE = 1 TO LC
  LEAP.YEAR = LEAP.YEAR.FUN( THE.DATE )
EXT THE.DATE
S = TIME()
RT TS - ST


T = TIME()
OR THE.DATE = 1 TO LC
 CALL LEAP.YEAR.SUB( LEAP.YEAR, THE.DATE )
EXT THE.DATE
S = TIME()
RT TS - ST

T = TIME()
OR THE.DATE = 1 TO LC
 $INSERT LEAP.YEAR.INS
EXT THE.DATE
S = TIME()
RT TS - ST

ND
The speed results:
unction 24 seconds
ubroutine 21 seconds
nsert 11 seconds
Not surprising results given what we know about these three methods.
lthough the function method did get better since the last time I've test
t.
UD 6.1
Other systems will vary.
But this is a good example of working together to enhance the U2 products,
ow we all have the same Leap Year calculation and those that were using the
OD(YEAR, 4) method should now use this method everywhere as to avoid data
orruption.
David A. Green
480) 813-1725
AG Consulting

Original Message-
rom: Daniel McGrath [mailto:dmcgr...@rocketsoftware.com] 
ent: Wednesday, December 07, 2011 11:57 AM
o: dgr...@dagconsulting.com; U2 Users List
ubject: RE: [U2] End of Month date routine
I added the code to PasteBin so as to not flood here:
ttp://pastebin.com/JMyqhFud
I did a few more than 100K and I cut the OCONV step out from all of them. I
ook the liberty to adjust Will's version to return correct results. The
esults I got, in order, was:
16.872
.804
.384
.561
So, if you have a need to account for your milliseconds, the slightly
ptimized Wikipedia algorithm seems to be the fastest.
Interested to see if there are any better? (Or if I made any mistakes...)
Regards,
an
-Original Message-
rom: u2-users-boun...@listserver.u2ug.org
mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of David A. Green
ent: Wednesday, December 07, 2011 10:48 AM
o: 'U2 Users List'
ubject: Re: [U2] End of Month date routine
Who wants to take each of the Leap Year calculations and put them into
ifferent subroutines and loop 100K times and see which one is faster using
rofiling?
David A. Green
480) 813-1725
AG Consulting
___
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


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 
oconv. On UV10.2, Pick flavour, the compiler didn't like the TODAY - TODAYDD 
+ 32 syntax and spat a nonnumeric data error when I tried to run it. You can 
see what the compiler has tried to do here, attempting to format (today - 
today) with (dd + 32):

2: EOM = TODAY - TODAYDD + 32
2 4 : 194 subTODAY TODAY  = $R0
2 C : 004 addDD 32  = $R1
2 00014 : 09C format $R0 $R1  = EOM


This variant works
 nowDate  = date()
 meDate= nowDate - oconv(nowDate,'dd') + 32
 meDate= meDate - oconv(meDate,'dd')

Cheers,
Stuart


___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] End of Month date routine

2011-12-07 Thread andy baum
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)) ANDMOD(YEAR,100)))
 
which took 1.423 seconds
 
Got the same trend, although different timings on our Solaris 10 box running 
Universe 10.3.6
 
Cheers,
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: 
http://pastebin.com/JMyqhFud

I did a few more than 100K and I cut the OCONV step out from all of them. I 
took the liberty to adjust Will's version to return correct results. The 
results I got, in order, was:

16.872
2.804
2.384
5.561

So, if you have a need to account for your milliseconds, the slightly optimized 
Wikipedia algorithm seems to be the fastest.

Interested to see if there are any better? (Or if I made any mistakes...)

Regards,
Dan

-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 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 is faster using 
profiling?

David A. Green
(480) 813-1725
DAG Consulting

___
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



LEAP.YEAR = (
 
which took 2.181 seconds but the fastest I could get at the moment is
 LEAP.YEAR = NOT(MOD(YEAR,4))IFLEAP.YEAR THEN    LEAP.YEAR = 
(NOT(MOD(YEAR,400)) ORMOD(YEAR,100))END
___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] End of Month date routine

2011-12-07 Thread andy baum
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)))
which took 2.181 seconds but the fastest I could get was

LEAP.YEAR = NOT(MOD(YEAR,4))
IF LEAP.YEAR THEN
       LEAP.YEAR = (NOT(MOD(YEAR,400)) OR MOD(YEAR,100))
END

which took 1.423 seconds

Got the same trend, although different timings on our Solaris 10 box running 
Universe 10.3.6

Cheers,
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: 
http://pastebin.com/JMyqhFud

I did a few more than 100K and I cut the OCONV step out from all of them. I 
took the liberty to adjust Will's version to return correct results. The 
results I got, in order, was:

16.872
2.804
2.384
5.561

So, if you have a need to account for your milliseconds, the slightly optimized 
Wikipedia algorithm seems to be the fastest.

Interested to see if there are any better? (Or if I made any mistakes...)

Regards,
Dan

-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 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 is faster using 
profiling?

David A. Green
(480) 813-1725
DAG Consulting

___
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


Re: [U2] End of Month date routine

2011-12-07 Thread andy baum
This is even worse on Universe, I passed YEAR into the Function/Subroutine so 
didn't have the OCONV but the results I got were


Function 13.008 seconds
Subroutine 12.889 seconds
Insert 1.455 seconds

Cheers,
Andy 




 From: David A. Green dgr...@dagconsulting.com
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) THEN
   LEAP.YEAR = 0
END ELSE
   IF MOD(YEAR, 100) THEN
      LEAP.YEAR = 1
   END ELSE 
      IF MOD(YEAR, 400) THEN LEAP.YEAR = 0 ELSE LEAP.YEAR = 1
   END
END

Then created a Function like:
FUNCTION LEAP.YEAR.FUN( THE.DATE )
$INSERT LEAP.YEAR.INS
RETURN LEAP.YEAR

And a Subroutine like:
SUBROUTINE LEAP.YEAR.SUB( LEAP.YEAR, THE.DATE )
$INSERT LEAP.YEAR.INS
RETURN

Then modified Daniel's test program like:
DEFFUN LEAP.YEAR.FUN( THE.DATE )
EQU LC TO 1000
*
ST = TIME()
FOR THE.DATE = 1 TO LC
   LEAP.YEAR = LEAP.YEAR.FUN( THE.DATE )
NEXT THE.DATE
TS = TIME()
CRT TS - ST
*
*
ST = TIME()
FOR THE.DATE = 1 TO LC
  CALL LEAP.YEAR.SUB( LEAP.YEAR, THE.DATE )
NEXT THE.DATE
TS = TIME()
CRT TS - ST
*
ST = TIME()
FOR THE.DATE = 1 TO LC
  $INSERT LEAP.YEAR.INS
NEXT THE.DATE
TS = TIME()
CRT TS - ST
*
END

The speed results:
Function 24 seconds
Subroutine 21 seconds
Insert 11 seconds

Not surprising results given what we know about these three methods.
Although the function method did get better since the last time I've test
it.

UD 6.1

Other systems will vary.

But this is a good example of working together to enhance the U2 products,
now we all have the same Leap Year calculation and those that were using the
MOD(YEAR, 4) method should now use this method everywhere as to avoid data
corruption.

David A. Green
(480) 813-1725
DAG Consulting


-Original Message-
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 100K and I cut the OCONV step out from all of them. I
took the liberty to adjust Will's version to return correct results. The
results I got, in order, was:

16.872
2.804
2.384
5.561

So, if you have a need to account for your milliseconds, the slightly
optimized Wikipedia algorithm seems to be the fastest.

Interested to see if there are any better? (Or if I made any mistakes...)

Regards,
Dan

-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 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 is faster using
profiling?

David A. Green
(480) 813-1725
DAG Consulting

___
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


Re: [U2] End of Month date routine

2011-12-07 Thread Wjhonson

 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 Message-
From: andy baum andyb...@yahoo.co.uk
To: U2 Users List u2-users@listserver.u2ug.org
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)))
which took 2.181 seconds but the fastest I could get was

LEAP.YEAR = NOT(MOD(YEAR,4))
IF LEAP.YEAR THEN
   LEAP.YEAR = (NOT(MOD(YEAR,400)) OR MOD(YEAR,100))
END

which took 1.423 seconds

Got the same trend, although different timings on our Solaris 10 box running 
Universe 10.3.6

Cheers,
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: 
http://pastebin.com/JMyqhFud

I did a few more than 100K and I cut the OCONV step out from all of them. I 
took 
the liberty to adjust Will's version to return correct results. The results I 
got, in order, was:

16.872
2.804
2.384
5.561

So, if you have a need to account for your milliseconds, the slightly optimized 
Wikipedia algorithm seems to be the fastest.

Interested to see if there are any better? (Or if I made any mistakes...)

Regards,
Dan

-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 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 is faster using profiling?

David A. Green
(480) 813-1725
DAG Consulting

___
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


Re: [U2] End of Month date routine

2011-12-07 Thread Boydell, Stuart
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 modYEAR 4  = $R1
0006A : 10E not$R1  = $R2
00070 : 0F6 modYEAR 400  = $R3
00078 : 10E not$R3  = $R4
0007E : 0F6 modYEAR 100  = $R5
00086 : 122 or $R4 $R5  = $R6
0008E : 008 and$R2 $R6  = LEAP.YEAR
00096 : 190 stop

I get minuscually better results using a case statement:

YEAR = oconv(THE.DATE, 'dy')
 begin case
 case mod(YEAR,4) ; LEAP.YEAR = @false
 case mod(YEAR,100); LEAP.YEAR = @true
 case mod(YEAR,400); LEAP.YEAR = @false
 case @true ; LEAP.YEAR = @true
 end case


-Original Message-
From: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson
Sent: Thursday, 8 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 ?





 

 

-Original Message-
From: andy baum andyb...@yahoo.co.uk
To: U2 Users List u2-users@listserver.u2ug.org
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))) which took 2.181 
seconds but the fastest I could get was

LEAP.YEAR = NOT(MOD(YEAR,4))
IF LEAP.YEAR THEN
   LEAP.YEAR = (NOT(MOD(YEAR,400)) OR MOD(YEAR,100)) END

which took 1.423 seconds

Got the same trend, although different timings on our Solaris 10 box running 
Universe 10.3.6

Cheers,
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: 
http://pastebin.com/JMyqhFud

I did a few more than 100K and I cut the OCONV step out from all of them. I 
took the liberty to adjust Will's version to return correct results. The 
results I got, in order, was:

16.872
2.804
2.384
5.561

So, if you have a need to account for your milliseconds, the slightly optimized 
Wikipedia algorithm seems to be the fastest.

Interested to see if there are any better? (Or if I made any mistakes...)

Regards,
Dan

-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 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 is faster using 
profiling?

David A. Green
(480) 813-1725
DAG Consulting

___
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



___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] End of Month date routine

2011-12-07 Thread andy baum
Stuart,


You are getting the performance from the case statement by having  
     
      case mod(YEAR,4) ; LEAP.YEAR = @false 


first, unfortunately when using case, the order is important and this needs to 
go just before the case @true. In your example


     
case mod(YEAR,400); LEAP.YEAR = @false 

will never be happen as it will already have been picked up by the previous case

Cheers,
Andy




 From: Boydell, Stuart stuart.boyd...@spotless.com.au
To: U2 Users List u2-users@listserver.u2ug.org 
Sent: Thursday, 8 December 2011, 6:44
Subject: 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  = $R3
00078 : 10E not            $R3  = $R4
0007E : 0F6 mod            YEAR 100  = $R5
00086 : 122 or             $R4 $R5  = $R6
0008E : 008 and            $R2 $R6  = LEAP.YEAR
00096 : 190 stop

I get minuscually better results using a case statement:

YEAR = oconv(THE.DATE, 'dy')
begin case
case mod(YEAR,4) ; LEAP.YEAR = @false
case mod(YEAR,100); LEAP.YEAR = @true
case mod(YEAR,400); LEAP.YEAR = @false
case @true ; LEAP.YEAR = @true
end case


-Original Message-
From: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson
Sent: Thursday, 8 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 ?









-Original Message-
From: andy baum andyb...@yahoo.co.uk
To: U2 Users List u2-users@listserver.u2ug.org
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))) which took 2.181 
seconds but the fastest I could get was

LEAP.YEAR = NOT(MOD(YEAR,4))
IF LEAP.YEAR THEN
           LEAP.YEAR = (NOT(MOD(YEAR,400)) OR MOD(YEAR,100)) END

which took 1.423 seconds

Got the same trend, although different timings on our Solaris 10 box running 
Universe 10.3.6

Cheers,
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: 
http://pastebin.com/JMyqhFud

I did a few more than 100K and I cut the OCONV step out from all of them. I 
took the liberty to adjust Will's version to return correct results. The 
results I got, in order, was:

16.872
2.804
2.384
5.561

So, if you have a need to account for your milliseconds, the slightly optimized 
Wikipedia algorithm seems to be the fastest.

Interested to see if there are any better? (Or if I made any mistakes...)

Regards,
Dan

-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 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 is faster using 
profiling?

David A. Green
(480) 813-1725
DAG Consulting

___
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



___
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


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 any screen...

I actually liked the 32 better. It just seemed to make a clearer connection
to next month for me.

-Original Message-
From: Wjhonson


I changed Marco's code slightly using Oconv to make it more clear what DD is
doing and make it more generic
I'm also adding 40 instead of 32 to make it clear that we don't care how
much we are adding as long as it's between 32 and 57
To make it clear what this is doing, we are taking the internal date, and
subtracting from that the day number on which we are running.
This will *always* give you the last day of the previous month.  Always.
Then we add enough to jump us into the next month anywhere, doesn't matter
at all.
And then do the same trick again, which will *always* give you the last day
of the month in which you are running
This is a fantastic bit of magic.


   TODAY = DATE() ; LAST.MO.END = TODAY - OCONV(TODAY,'DD')
   A.DAY.NEXT.MO = LAST.MO.END + 40
   END.OF.MO.DATE = A.DAY.NEXT.MO - OCONV(A.DAY.NEXT.MO,'DD')


___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] End of Month date routine

2011-12-06 Thread John Hatherill


Tdate = OCONV(DATE(),D4-)
mm1= Tdate[1,2]+1
1 = Tdate[7,4]
if mm1  12 then
  mm1 = 01
  1 += 1
end
EDATE = ICONV(mm1:-01-:1,D4-) - 1
EDATE = OCONV(EDATE,D2/); here is external format end-of-month 

-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 a single date conversion, though 
 will admit that it gets a little too obscure to be considered maintainable.  
dmittedly, there are probably easier ways to tell how many days there are in a 
onth, but they may not be as much fun!
Rick Nuckolls
ynden Inc

extdate = oconv( d, 'D4-YMD')
 year = field(extdate, '-',1)
month = field( extdate, '-', 2)
dom = field(extdate,'-',3)
 if month = 2 then
   daysinmonth = 28 + ( not(mod(year,4))  ( mod(year,100) ! 
ot(mod(year,400)) ))
end else
   daysinmonth = 30 + mod( if month  8 then abs(month-2) else month-7, 
)
end
 lastdayofmonth = d - dom + daysinmonth

n Dec 5, 2011, at 2:26 PM, Wjhonson wrote:
 
 I changed Marco's code slightly using Oconv to make it more clear what DD is 
oing and make it more generic
 I'm also adding 40 instead of 32 to make it clear that we don't care how much 
e are adding as long as it's between 32 and 57
 To make it clear what this is doing, we are taking the internal date, and 
ubtracting from that the day number on which we are running.
 This will *always* give you the last day of the previous month.  Always.
 Then we add enough to jump us into the next month anywhere, doesn't matter at 
ll.
 And then do the same trick again, which will *always* give you the last day of 
he month in which you are running
 This is a fantastic bit of magic.
 
 
   TODAY = DATE() ; LAST.MO.END = TODAY - OCONV(TODAY,'DD')
   A.DAY.NEXT.MO = LAST.MO.END + 40
   END.OF.MO.DATE = A.DAY.NEXT.MO - OCONV(A.DAY.NEXT.MO,'DD')
 
 
 
 
 -Original Message-
 From: 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 is vendor independent, but it could be 
ade 
 o, by merely using OCONV(TODAY, 'DD') instead
 
 -Original Message-
 rom: Marco Antonio Rojas Castro marco_roja...@hotmail.com
 o: u2-users u2-users@listserver.u2ug.org
 ent: Mon, Dec 5, 2011 12:49 pm
 ubject: Re: [U2] End of Month date routine
 
 ODAY = DATE()
 M = TODAY - TODAYDD + 32
 M = 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
 but the attempt to iconv that sets it to zero, it doesn't pad the 01 into it 
 something
 so i just get 31 at that point.
 
 I think you were expecting that it would take 12 2011 and make it into 12 
 2011 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 you 
 arch, backing up
 Will give you 02/xx (28 or 29)?
 George
 -Original Message-
 rom: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] 
 n 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 date, is the calendar end of month date not some 
 crewy business date)
 Hmmm... no-one seems to have done my approach ...
 TODAY = @DATE
 HIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off
 EXT.MONTH.I = ICONV( THIS.MONTH.O, D) + 31 ;* random day next month
 EXT.MONTH.O = OCONV( NEXT.MONTH.I, DMY) ;* strip day off
 AST.DAY.I = ICONV( NEXT.MONTH.O, D) - 1 ;* subract one day
 If you don't have a day in your i/oconv it defaults to 1, so the logic 
 orks. Unfortunately you can't combine the first three lines because 
 here's no number you can pick that will guarantee to land you in next 
 onth whatever today's date :-(
 Cheers,
 ol
 __
 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

Re: [U2] End of Month date routine

2011-12-06 Thread Holt, Jake
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



-Original Message-
From: u2-users-boun...@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 = ICONV(mm1:-01-:1,D4-) - 1 EDATE =
OCONV(EDATE,D2/); here is external format end-of-month 

-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 a single date conversion,
though  will admit that it gets a little too obscure to be considered
maintainable.  
dmittedly, there are probably easier ways to tell how many days there
are in a onth, but they may not be as much fun!
Rick Nuckolls
ynden Inc

extdate = oconv( d, 'D4-YMD')
 year = field(extdate, '-',1)
month = field( extdate, '-', 2)
dom = field(extdate,'-',3)
 if month = 2 then
   daysinmonth = 28 + ( not(mod(year,4))  ( mod(year,100) ! 
ot(mod(year,400)) ))
end else
   daysinmonth = 30 + mod( if month  8 then abs(month-2) else
month-7,
)
end
 lastdayofmonth = d - dom + daysinmonth

n Dec 5, 2011, at 2:26 PM, Wjhonson wrote:
 
 I changed Marco's code slightly using Oconv to make it more clear what
DD is oing and make it more generic  I'm also adding 40 instead of 32 to
make it clear that we don't care how much e are adding as long as it's
between 32 and 57  To make it clear what this is doing, we are taking
the internal date, and ubtracting from that the day number on which we
are running.
 This will *always* give you the last day of the previous month.
Always.
 Then we add enough to jump us into the next month anywhere, doesn't
matter at ll.
 And then do the same trick again, which will *always* give you the last
day of he month in which you are running  This is a fantastic bit of
magic.
 
 
   TODAY = DATE() ; LAST.MO.END = TODAY - OCONV(TODAY,'DD')
   A.DAY.NEXT.MO = LAST.MO.END + 40
   END.OF.MO.DATE = A.DAY.NEXT.MO - OCONV(A.DAY.NEXT.MO,'DD')
 
 
 
 
 -Original Message-
 From: 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 is
vendor independent, but it could be ade  o, by merely using OCONV(TODAY,
'DD') instead
 
 -Original Message-
 rom: Marco Antonio Rojas Castro marco_roja...@hotmail.com
 o: u2-users u2-users@listserver.u2ug.org
 ent: Mon, Dec 5, 2011 12:49 pm
 ubject: Re: [U2] End of Month date routine
 
 ODAY = DATE()
 M = TODAY - TODAYDD + 32
 M = 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  but the attempt to iconv
that sets it to zero, it doesn't pad the 01 into it 
 something
 so i just get 31 at that point.
 
 I think you were expecting that it would take 12 2011 and make it
into 12  2011 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 you 
 arch, backing up
 Will give you 02/xx (28 or 29)?
 George
 -Original Message-
 rom: u2-users-boun...@listserver.u2ug.org
[mailto:u2-users-boun...@listserver.u2ug.org] 
 n 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 date, is the calendar end of month date not
some  crewy business date)  Hmmm... no-one seems to have done my
approach ...
 TODAY = @DATE
 HIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off  EXT.MONTH.I =
ICONV( THIS.MONTH.O, D) + 31 ;* random day next month  EXT.MONTH.O =
OCONV( NEXT.MONTH.I, DMY) ;* strip day off  AST.DAY.I = ICONV(
NEXT.MONTH.O, D) - 1 ;* subract one day  If you don't have a day in
your i/oconv it defaults to 1, so the logic  orks. Unfortunately you
can't combine the first three lines because  here's

Re: [U2] End of Month date routine

2011-12-06 Thread John Hester
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 = 30
MONTHS7 = 31
MONTHS8 = 31
MONTHS9 = 30
MONTHS10 = 31
MONTHS11 = 30
MONTHS12 = 31
LAST.DAY = MONTHSMONTH

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


Re: [U2] End of Month date routine

2011-12-06 Thread Daniel McGrath
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 = ''
MONTHS1 = 31
MONTHS2 = 28 + LEAP
MONTHS3 = 31
MONTHS4 = 30
MONTHS5 = 31
MONTHS6 = 30
MONTHS7 = 31
MONTHS8 = 31
MONTHS9 = 30
MONTHS10 = 31
MONTHS11 = 30
MONTHS12 = 31
LAST.DAY = MONTHSMONTH

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


Re: [U2] End of Month date routine

2011-12-06 Thread Wjhonson

Can I *improve* on your method?
Months = '31,':(28+Leap):',31,30,31,30,31,31,30,31,30,31'
Last.day = FIELD(Months,,,Month)



-Original Message-
From: John Hester jhes...@momtex.com
To: U2 Users List u2-users@listserver.u2ug.org
Sent: Tue, Dec 6, 2011 3:15 pm
Subject: Re: [U2] End of Month date routine


Your method is also the way I've always done it, but an alternate method
ust came to mind:
MONTH = OCONV(DATE, 'DM')
EAR = OCONV(DATE, 'D Y[Z4]')
EAP = MOD(YEAR, 4) = 0
ONTHS = ''
ONTHS1 = 31
ONTHS2 = 28 + LEAP
ONTHS3 = 31
ONTHS4 = 30
ONTHS5 = 31
ONTHS6 = 30
ONTHS7 = 31
ONTHS8 = 31
ONTHS9 = 30
ONTHS10 = 31
ONTHS11 = 30
ONTHS12 = 31
AST.DAY = MONTHSMONTH
Not very concise, but you can tell at a glance how many days your
ealing with.  
-Original Message-
rom: u2-users-boun...@listserver.u2ug.org
mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Holt, Jake
ent: 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/:YEAR,'D')-1
__
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


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
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] End of Month date routine

2011-12-05 Thread Dave Davis
Month = Oconv(current.date,'DM') ;* find month
Year = Oconv(current.date,'DY') ;* find year
Month = Month + 1 ;* find next month
If (Month  12) then
   Month = 1
   Year = Year + 1
End
FirstDayNextMonth = Iconv(Month:/01/:Year,'D') ;* assumes MM/DD/ format
LastDayThisMonth = 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 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@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users



Dave Davis
Team Lead, RD

P: 614-875-4910 x108
F: 614-875-4088
E: dda...@harriscomputer.com
[http://www.harriscomputer.com/images/signatures/HarrisSchools.gif]

[http://www.harriscomputer.com/images/signatures/DivisionofHarris.gif]http://www.harriscomputer.com/
6110 Enterprise Parkway
Grove City, OH
43123
www.harris-schoolsolutions.comhttp://www.harris-schoolsolutions.com

This message is intended exclusively for the individual or entity to which it 
is addressed. This communication may contain information that is proprietary, 
privileged or confidential or otherwise legally exempt from disclosure. If you 
are not the named addressee, you are not authorized to read, print, retain, 
copy or disseminate this message or any part of it. If you have received this 
message in error, please notify the sender immediately by e-mail and delete all 
copies of the message.

___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


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 the calendar end of month date not some
 screwy business date)
 ___
 U2-Users mailing list
 U2-Users@listserver.u2ug.org
 http://listserver.u2ug.org/mailman/listinfo/u2-users




-- 

*hp*
___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] End of Month date routine

2011-12-05 Thread John Thompson
This may not be the cleanest way, but, we use it here and it works.
I used ABORT, so some parent program or paragraph would not keep executing.

  IF FIELD(OCONV(DATE()+1,D2/),/,2) + 0 = 1 THEN
 CRT 'This IS the last day of the month.'
 CRT 'ABORTING END OF DAY'
 ABORT
  END ELSE
 CRT 'This is NOT the last day of the month'
 CRT 'Running End of Day'
  END

Whatever you do... Do it in BASIC.  Don't go down the road of unix shell
scripting unless you love that stuff.

On Mon, Dec 5, 2011 at 2:08 PM, Dave Davis dda...@harriscomputer.comwrote:

 Month = Oconv(current.date,'DM') ;* find month
 Year = Oconv(current.date,'DY') ;* find year
 Month = Month + 1 ;* find next month
 If (Month  12) then
   Month = 1
   Year = Year + 1
 End
 FirstDayNextMonth = Iconv(Month:/01/:Year,'D') ;* assumes MM/DD/
 format
 LastDayThisMonth = 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 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@listserver.u2ug.org
 http://listserver.u2ug.org/mailman/listinfo/u2-users
 


 Dave Davis
 Team Lead, RD

 P: 614-875-4910 x108
 F: 614-875-4088
 E: dda...@harriscomputer.com
[http://www.harriscomputer.com/images/signatures/HarrisSchools.gif]

 [http://www.harriscomputer.com/images/signatures/DivisionofHarris.gif]
 http://www.harriscomputer.com/
6110 Enterprise Parkway
 Grove City, OH
 43123
 www.harris-schoolsolutions.comhttp://www.harris-schoolsolutions.com

 This message is intended exclusively for the individual or entity to which
 it is addressed. This communication may contain information that is
 proprietary, privileged or confidential or otherwise legally exempt from
 disclosure. If you are not the named addressee, you are not authorized to
 read, print, retain, copy or disseminate this message or any part of it. If
 you have received this message in error, please notify the sender
 immediately by e-mail and delete all copies of the message.

 ___
 U2-Users mailing list
 U2-Users@listserver.u2ug.org
 http://listserver.u2ug.org/mailman/listinfo/u2-users




-- 
John Thompson
___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] End of Month date routine

2011-12-05 Thread Wjhonson

Thanks John. Your routine below can be a little more efficient by using the DD 
conversion which returns the day number
IF OCONV(DATE()+1,'DD) = 1 THEN
   CRT 'This is the last day...'

etc
Also, You don't need to add one, Universe handles the string to numeric 
properly even though the string 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 program or paragraph would not keep executing.
  IF FIELD(OCONV(DATE()+1,D2/),/,2) + 0 = 1 THEN
CRT 'This IS the last day of the month.'
CRT 'ABORTING END OF DAY'
ABORT
 END ELSE
CRT 'This is NOT the last day of the month'
CRT 'Running End of Day'
 END
Whatever you do... Do it in BASIC.  Don't go down the road of unix shell
cripting unless you love that stuff.
On Mon, Dec 5, 2011 at 2:08 PM, Dave Davis dda...@harriscomputer.comwrote:
 Month = Oconv(current.date,'DM') ;* find month
 Year = Oconv(current.date,'DY') ;* find year
 Month = Month + 1 ;* find next month
 If (Month  12) then
   Month = 1
   Year = Year + 1
 End
 FirstDayNextMonth = Iconv(Month:/01/:Year,'D') ;* assumes MM/DD/
 format
 LastDayThisMonth = 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 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@listserver.u2ug.org
 http://listserver.u2ug.org/mailman/listinfo/u2-users
 


 Dave Davis
 Team Lead, RD

 P: 614-875-4910 x108
 F: 614-875-4088
 E: dda...@harriscomputer.com
[http://www.harriscomputer.com/images/signatures/HarrisSchools.gif]

 [http://www.harriscomputer.com/images/signatures/DivisionofHarris.gif]
 http://www.harriscomputer.com/
6110 Enterprise Parkway
 Grove City, OH
 43123
 www.harris-schoolsolutions.comhttp://www.harris-schoolsolutions.com

 This message is intended exclusively for the individual or entity to which
 it is addressed. This communication may contain information that is
 proprietary, privileged or confidential or otherwise legally exempt from
 disclosure. If you are not the named addressee, you are not authorized to
 read, print, retain, copy or disseminate this message or any part of it. If
 you have received this message in error, please notify the sender
 immediately by e-mail and delete all copies of the message.

 ___
 U2-Users mailing list
 U2-Users@listserver.u2ug.org
 http://listserver.u2ug.org/mailman/listinfo/u2-users


-- 
ohn Thompson
__
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


Re: [U2] End of Month date routine

2011-12-05 Thread Charles_Shaffer
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 Analyst
NTN-Bower Corporation



From:   Wjhonson wjhon...@aol.com
To: u2-users@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 of month date not some 
screwy business date)
___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

-- 
This email was Anti Virus checked by Astaro Security Gateway. 
http://www.astaro.com

___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] End of Month date routine

2011-12-05 Thread Dave Laansma
* BASICALLY, GET TO THE FIRST OF NEXT MONTH
*   THEN BACK UP ONE DAY

  TODAY  = ICONV(12/15/11,D2/) ; * SAMPLE DATE
  THIS.MONTH = OCONV(TODAY,DM)   ; * GET 'THIS' MONTH NUMBER
  LAST.DAY   = TODAY   ; * ASSUME TODAY IS THE LAST DAY

  LOOP
IF OCONV(LAST.DAY,DM) # THIS.MONTH THEN ; * CHANGE IN MONTH?
  LAST.DAY -= 1   ; * BACK UP A DAY
  EXIT; * DONE
END

LAST.DAY += 1 ; * GO FORWARD A DAY
  REPEAT

Sincerely,
David Laansma
IT Manager
Hubbard Supply Co.
Direct: 810-342-7143
Office: 810-234-8681
Fax: 810-234-6142
www.hubbardsupply.com
Delivering Products, Services and Innovative Solutions


-Original Message-
From: u2-users-boun...@listserver.u2ug.org
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of
charles_shaf...@ntn-bower.com
Sent: 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 Analyst
NTN-Bower Corporation



From:   Wjhonson wjhon...@aol.com
To: u2-users@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 of month date not
some screwy business date)
___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

--
This email was Anti Virus checked by Astaro Security Gateway. 
http://www.astaro.com

___
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


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 point of line 3 is for clarity so the next programmer doesn't stare at 
this for ten minutes going WTH?
You could combine 3 and 4 into a single line
END.OF.MONTH.DATE = ICONV(MONTH:'/01/':YEAR,'D')-1



___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


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 = @DATE
THIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off
NEXT.MONTH.I = ICONV( THIS.MONTH.O, D) + 31 ;* random day next month
NEXT.MONTH.O = OCONV( NEXT.MONTH.I, DMY) ;* strip day off
LAST.DAY.I = ICONV( NEXT.MONTH.O, D) - 1 ;* subract one day

If you don't have a day in your i/oconv it defaults to 1, so the logic 
works. Unfortunately you can't combine the first three lines because 
there's no number you can pick that will guarantee to land you in next 
month whatever today's date :-(


Cheers,
Wol
___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] End of Month date routine

2011-12-05 Thread George Gallen
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

-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 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 = @DATE
THIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off
NEXT.MONTH.I = ICONV( THIS.MONTH.O, D) + 31 ;* random day next month
NEXT.MONTH.O = OCONV( NEXT.MONTH.I, DMY) ;* strip day off
LAST.DAY.I = ICONV( NEXT.MONTH.O, D) - 1 ;* subract one day

If you don't have a day in your i/oconv it defaults to 1, so the logic 
works. Unfortunately you can't combine the first three lines because 
there's no number you can pick that will guarantee to land you in next 
month whatever today's date :-(

Cheers,
Wol
___
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


Re: [U2] End of Month date routine

2011-12-05 Thread Wjhonson

Doesn't work on my system Anthony.
The This month o gives the month and year ok
but the attempt to iconv that sets it to zero, it doesn't pad the 01 into it 
or something
so i just get 31 at that point.

I think you were expecting that it would take 12 2011 and make it into 12 01 
2011 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 you 
arch, backing up
 Will give you 02/xx (28 or 29)?
George
-Original Message-
rom: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] 
n 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 date, is the calendar end of month date not some 
crewy business date)
Hmmm... no-one seems to have done my approach ...
TODAY = @DATE
HIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off
EXT.MONTH.I = ICONV( THIS.MONTH.O, D) + 31 ;* random day next month
EXT.MONTH.O = OCONV( NEXT.MONTH.I, DMY) ;* strip day off
AST.DAY.I = ICONV( NEXT.MONTH.O, D) - 1 ;* subract one day
If you don't have a day in your i/oconv it defaults to 1, so the logic 
orks. Unfortunately you can't combine the first three lines because 
here's no number you can pick that will guarantee to land you in next 
onth whatever today's date :-(
Cheers,
ol
__
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


Re: [U2] End of Month date routine

2011-12-05 Thread Dave Laansma
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 Products, Services and Innovative Solutions


-Original Message-
From: u2-users-boun...@listserver.u2ug.org
[mailto:u2-users-boun...@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

-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 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 = @DATE
THIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off NEXT.MONTH.I =
ICONV( THIS.MONTH.O, D) + 31 ;* random day next month NEXT.MONTH.O =
OCONV( NEXT.MONTH.I, DMY) ;* strip day off LAST.DAY.I = ICONV(
NEXT.MONTH.O, D) - 1 ;* subract one day

If you don't have a day in your i/oconv it defaults to 1, so the logic
works. Unfortunately you can't combine the first three lines because
there's no number you can pick that will guarantee to land you in next
month whatever today's date :-(

Cheers,
Wol
___
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


Re: [U2] End of Month date routine

2011-12-05 Thread George Gallen
Damn February...We need to pull a day from two of the 31 months and give them 
to February
So it will have 30 or 31 days, and almost be like a normal month (all will have 
30 or 31 days).

-Original Message-
From: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@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 Products, Services and Innovative Solutions


-Original Message-
From: u2-users-boun...@listserver.u2ug.org
[mailto:u2-users-boun...@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

-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 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 = @DATE
THIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off NEXT.MONTH.I =
ICONV( THIS.MONTH.O, D) + 31 ;* random day next month NEXT.MONTH.O =
OCONV( NEXT.MONTH.I, DMY) ;* strip day off LAST.DAY.I = ICONV(
NEXT.MONTH.O, D) - 1 ;* subract one day

If you don't have a day in your i/oconv it defaults to 1, so the logic
works. Unfortunately you can't combine the first three lines because
there's no number you can pick that will guarantee to land you in next
month whatever today's date :-(

Cheers,
Wol
___
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


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 to pull a day from two of the 31 months and give them 
to February So it will have 30 or 31 days, and almost be like a normal month 
(all will have 30 or 31 days).

-Original Message-
From: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@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 Products, Services and Innovative Solutions


-Original Message-
From: u2-users-boun...@listserver.u2ug.org
[mailto:u2-users-boun...@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

-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 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 = @DATE
THIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off NEXT.MONTH.I = ICONV( 
THIS.MONTH.O, D) + 31 ;* random day next month NEXT.MONTH.O = OCONV( 
NEXT.MONTH.I, DMY) ;* strip day off LAST.DAY.I = ICONV( NEXT.MONTH.O, D) - 
1 ;* subract one day

If you don't have a day in your i/oconv it defaults to 1, so the logic works. 
Unfortunately you can't combine the first three lines because there's no number 
you can pick that will guarantee to land you in next month whatever today's 
date :-(

Cheers,
Wol
___
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
___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] End of Month date routine

2011-12-05 Thread George Gallen
It would also mess up the knuckle method too, I couldn't never remember the 
rhyme, but the knuckle method
Always came through.

http://lifehacker.com/232828/macgyver-tip-use-your-knuckles-to-remember-each-months-days

-Original Message-
From: u2-users-boun...@listserver.u2ug.org 
[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...@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 to pull a day from two of the 31 months and give them 
to February So it will have 30 or 31 days, and almost be like a normal month 
(all will have 30 or 31 days).

-Original Message-
From: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@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 Products, Services and Innovative Solutions


-Original Message-
From: u2-users-boun...@listserver.u2ug.org
[mailto:u2-users-boun...@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

-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 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 = @DATE
THIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off NEXT.MONTH.I = ICONV( 
THIS.MONTH.O, D) + 31 ;* random day next month NEXT.MONTH.O = OCONV( 
NEXT.MONTH.I, DMY) ;* strip day off LAST.DAY.I = ICONV( NEXT.MONTH.O, D) - 
1 ;* subract one day

If you don't have a day in your i/oconv it defaults to 1, so the logic works. 
Unfortunately you can't combine the first three lines because there's no number 
you can pick that will guarantee to land you in next month whatever today's 
date :-(

Cheers,
Wol
___
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
___
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


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
 but the attempt to iconv that sets it to zero, it doesn't pad the 01 into 
 it or something
 so i just get 31 at that point.
 
 I think you were expecting that it would take 12 2011 and make it into 12 
 01 2011 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 
 you 
 arch, backing up
 Will give you 02/xx (28 or 29)?
 George
 -Original Message-
 rom: u2-users-boun...@listserver.u2ug.org 
 [mailto:u2-users-boun...@listserver.u2ug.org] 
 n 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 date, is the calendar end of month date not some 
 crewy business date)
 Hmmm... no-one seems to have done my approach ...
 TODAY = @DATE
 HIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off
 EXT.MONTH.I = ICONV( THIS.MONTH.O, D) + 31 ;* random day next month
 EXT.MONTH.O = OCONV( NEXT.MONTH.I, DMY) ;* strip day off
 AST.DAY.I = ICONV( NEXT.MONTH.O, D) - 1 ;* subract one day
 If you don't have a day in your i/oconv it defaults to 1, so the logic 
 orks. Unfortunately you can't combine the first three lines because 
 here's no number you can pick that will guarantee to land you in next 
 onth whatever today's date :-(
 Cheers,
 ol
 __
 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
  
___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


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, Canada

-Original Message-
From: 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 point of line 3 is for clarity so the next programmer doesn't stare
at this for ten minutes going WTH?
You could combine 3 and 4 into a single line
END.OF.MONTH.DATE = ICONV(MONTH:'/01/':YEAR,'D')-1


___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] End of Month date routine

2011-12-05 Thread Dave Laansma
No, this will fail on January 31st, every year.

Sincerely,
David Laansma
IT Manager
Hubbard Supply Co.
Direct: 810-342-7143
Office: 810-234-8681
Fax: 810-234-6142
www.hubbardsupply.com
Delivering Products, Services and Innovative Solutions


-Original Message-
From: u2-users-boun...@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@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 but the attempt to iconv 
 that sets it to zero, it doesn't pad the 01 into it or something so 
 i just get 31 at that point.
 
 I think you were expecting that it would take 12 2011 and make it 
 into 12 01 2011 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 you arch, backing up Will give you 02/xx (28 or 29)?
 George
 -Original Message-
 rom: u2-users-boun...@listserver.u2ug.org 
 [mailto:u2-users-boun...@listserver.u2ug.org]
 n 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 date, is the calendar end of month date not 
 some crewy business date) Hmmm... no-one seems to have done my 
 approach ...
 TODAY = @DATE
 HIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off EXT.MONTH.I = 
 ICONV( THIS.MONTH.O, D) + 31 ;* random day next month EXT.MONTH.O = 
 OCONV( NEXT.MONTH.I, DMY) ;* strip day off AST.DAY.I = ICONV( 
 NEXT.MONTH.O, D) - 1 ;* subract one day If you don't have a day in 
 your i/oconv it defaults to 1, so the logic orks. Unfortunately you 
 can't combine the first three lines because here's no number you can 
 pick that will guarantee to land you in next onth whatever today's 
 date :-( Cheers, ol __
 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
  
___
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


Re: [U2] End of Month date routine

2011-12-05 Thread Marco Antonio Rojas Castro

TODAY = ICONV(31 JAN 2011, D)   ;* 15737
EOM = TODAY - TODAYDD + 32;* 15737 - 31 + 32 = 15738
EOM = EOM - EOMDD  ;* 15738 - 15738DD
PRINT EOM   ;* 15738 - 1 = 15737
* OCONV(15737, D) = 31 JAN 2011
* WORKS FINE - UDT 7.1.7 (AIX)

 

 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-8681
 Fax: 810-234-6142
 www.hubbardsupply.com
 Delivering Products, Services and Innovative Solutions
 
 
 -Original Message-
 From: u2-users-boun...@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@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 but the attempt to iconv 
  that sets it to zero, it doesn't pad the 01 into it or something so 
  i just get 31 at that point.
  
  I think you were expecting that it would take 12 2011 and make it 
  into 12 01 2011 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 you arch, backing up Will give you 02/xx (28 or 29)?
  George
  -Original Message-
  rom: u2-users-boun...@listserver.u2ug.org 
  [mailto:u2-users-boun...@listserver.u2ug.org]
  n 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 date, is the calendar end of month date not 
  some crewy business date) Hmmm... no-one seems to have done my 
  approach ...
  TODAY = @DATE
  HIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off EXT.MONTH.I = 
  ICONV( THIS.MONTH.O, D) + 31 ;* random day next month EXT.MONTH.O = 
  OCONV( NEXT.MONTH.I, DMY) ;* strip day off AST.DAY.I = ICONV( 
  NEXT.MONTH.O, D) - 1 ;* subract one day If you don't have a day in 
  your i/oconv it defaults to 1, so the logic orks. Unfortunately you 
  can't combine the first three lines because here's no number you can 
  pick that will guarantee to land you in next onth whatever today's 
  date :-( Cheers, ol __
  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
 
 ___
 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


Re: [U2] End of Month date routine

2011-12-05 Thread Rick Nuckolls
I think that with a slight modification, adding 31 works reasonably well.

Just use the “DYM” conversion consistently through the program:

To be concise, in Universe, for any internal date, “D”, the internal form of 
the last day of the month is:

lastdayofmonth = iconv(oconv(iconv(oconv( D, 'DMY'), 'DMY') +31 ,'DMY'),'DMY') 
-1

“DYM” would work as well.

Rick Nuckolls
Lynden Inc

 
 Doesn't work on my system Anthony.
 The This month o gives the month and year ok
 but the attempt to iconv that sets it to zero, it doesn't pad the 01 into 
 it or something
 so i just get 31 at that point.
 
 I think you were expecting that it would take 12 2011 and make it into 12 
 01 2011 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 
 you 
 arch, backing up
 Will give you 02/xx (28 or 29)?
 George
 -Original Message-
 rom: u2-users-boun...@listserver.u2ug.org 
 [mailto:u2-users-boun...@listserver.u2ug.org] 
 n 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 date, is the calendar end of month date not some 
 crewy business date)
 Hmmm... no-one seems to have done my approach ...
 TODAY = @DATE
 HIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off
 EXT.MONTH.I = ICONV( THIS.MONTH.O, D) + 31 ;* random day next month
 EXT.MONTH.O = OCONV( NEXT.MONTH.I, DMY) ;* strip day off
 AST.DAY.I = ICONV( NEXT.MONTH.O, D) - 1 ;* subract one day
 If you don't have a day in your i/oconv it defaults to 1, so the logic 
 orks. Unfortunately you can't combine the first three lines because 
 here's no number you can pick that will guarantee to land you in next 
 onth whatever today's date :-(
 Cheers,
 ol
 __
 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

___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] End of Month date routine

2011-12-05 Thread Charlie Noah
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 31, 32, etc. will bite 
you sooner or later (well, it worked at my last job).


Regards,

Charlie Noah
Charles W. Noah Associates
cwn...@comcast.net

http://www.linkedin.com/in/charlienoah

The views and opinions expressed herein are my own (Charlie Noah) and do 
not necessarily reflect the views, positions or policies of any of my 
former, current or future employers, employees, clients, friends, 
enemies or anyone else who might take exception to them.



On 12-05-2011 3:12 PM, Rick Nuckolls wrote:

I think that with a slight modification, adding 31 works reasonably well.

Just use the “DYM” conversion consistently through the program:

To be concise, in Universe, for any internal date, “D”, the internal form of 
the last day of the month is:

lastdayofmonth = iconv(oconv(iconv(oconv( D, 'DMY'), 'DMY') +31 ,'DMY'),'DMY') 
-1

“DYM” would work as well.

Rick Nuckolls
Lynden Inc


Doesn't work on my system Anthony.
The This month o gives the month and year ok
but the attempt to iconv that sets it to zero, it doesn't pad the 01 into it 
or something
so i just get 31 at that point.

I think you were expecting that it would take 12 2011 and make it into 12 01 
2011 or whatever
but it's not working




-Original Message-
From: George Gallenggal...@wyanokegroup.com
To: U2 Users 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...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org]
n 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 date, is the calendar end of month date not some
crewy business date)
Hmmm... no-one seems to have done my approach ...
TODAY = @DATE
HIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off
EXT.MONTH.I = ICONV( THIS.MONTH.O, D) + 31 ;* random day next month
EXT.MONTH.O = OCONV( NEXT.MONTH.I, DMY) ;* strip day off
AST.DAY.I = ICONV( NEXT.MONTH.O, D) - 1 ;* subract one day
If you don't have a day in your i/oconv it defaults to 1, so the logic
orks. Unfortunately you can't combine the first three lines because
here's no number you can pick that will guarantee to land you in next
onth whatever today's date :-(
Cheers,
ol
__
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

___
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


Re: [U2] End of Month date routine

2011-12-05 Thread Israel, John R.
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
Fax: 937-865-9182

johnisr...@daytonsuperior.com

This message w/attachments (message) is intended solely for the use of the 
intended recipient(s) and may contain information that is privileged, 
confidential or proprietary. If you are not an intended recipient, please 
notify the sender, and then please delete and destroy all copies and 
attachments, and be advised that any review or dissemination of, or the taking 
of any action in reliance on, the information contained in or attached to this 
message is prohibited.




-Original Message-
From: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf 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 31, 32, etc. will bite
you sooner or later (well, it worked at my last job).

Regards,

Charlie Noah
Charles W. Noah Associates
cwn...@comcast.net

http://www.linkedin.com/in/charlienoah

The views and opinions expressed herein are my own (Charlie Noah) and do
not necessarily reflect the views, positions or policies of any of my
former, current or future employers, employees, clients, friends,
enemies or anyone else who might take exception to them.


On 12-05-2011 3:12 PM, Rick Nuckolls wrote:
 I think that with a slight modification, adding 31 works reasonably well.

 Just use the DYM conversion consistently through the program:

 To be concise, in Universe, for any internal date, D, the internal form of 
 the last day of the month is:

 lastdayofmonth = iconv(oconv(iconv(oconv( D, 'DMY'), 'DMY') +31 
 ,'DMY'),'DMY') -1

 DYM would work as well.

 Rick Nuckolls
 Lynden Inc

 Doesn't work on my system Anthony.
 The This month o gives the month and year ok
 but the attempt to iconv that sets it to zero, it doesn't pad the 01 into 
 it or something
 so i just get 31 at that point.

 I think you were expecting that it would take 12 2011 and make it into 12 
 01 2011 or whatever
 but it's not working




 -Original Message-
 From: George Gallenggal...@wyanokegroup.com
 To: U2 Users 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...@listserver.u2ug.org 
 [mailto:u2-users-boun...@listserver.u2ug.org]
 n 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 date, is the calendar end of month date not some
 crewy business date)
 Hmmm... no-one seems to have done my approach ...
 TODAY = @DATE
 HIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off
 EXT.MONTH.I = ICONV( THIS.MONTH.O, D) + 31 ;* random day next month
 EXT.MONTH.O = OCONV( NEXT.MONTH.I, DMY) ;* strip day off
 AST.DAY.I = ICONV( NEXT.MONTH.O, D) - 1 ;* subract one day
 If you don't have a day in your i/oconv it defaults to 1, so the logic
 orks. Unfortunately you can't combine the first three lines because
 here's no number you can pick that will guarantee to land you in next
 onth whatever today's date :-(
 Cheers,
 ol
 __
 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
 ___
 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


Re: [U2] End of Month date routine

2011-12-05 Thread Phil Walker

EOM = 
OCONV(ICONV(OCONV(@DATE+31,'D-YM[4,2]'):'-01','D-YMD[4,2,2')-1,'D-YMD[4,2,2]')


 -Original Message-
 From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-
 boun...@listserver.u2ug.org] On Behalf Of Israel, John R.
 Sent: Tuesday, 6 December 2011 10:29 a.m.
 To: 'U2 Users 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
 Fax: 937-865-9182
 
 johnisr...@daytonsuperior.com
 
 This message w/attachments (message) is intended solely for the use of the
 intended recipient(s) and may contain information that is privileged,
 confidential or proprietary. If you are not an intended recipient, please
 notify the sender, and then please delete and destroy all copies and
 attachments, and be advised that any review or dissemination of, or the
 taking of any action in reliance on, the information contained in or
 attached to this message is prohibited.
 
 
 
 
 -Original Message-
 From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-
 boun...@listserver.u2ug.org] On Behalf 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 31, 32, etc. will bite you sooner
 or later (well, it worked at my last job).
 
 Regards,
 
 Charlie Noah
 Charles W. Noah Associates
 cwn...@comcast.net
 
 http://www.linkedin.com/in/charlienoah
 
 The views and opinions expressed herein are my own (Charlie Noah) and
 do not necessarily reflect the views, positions or policies of any of my
 former, current or future employers, employees, clients, friends, enemies or
 anyone else who might take exception to them.
 
 
 On 12-05-2011 3:12 PM, Rick Nuckolls wrote:
  I think that with a slight modification, adding 31 works reasonably well.
 
  Just use the DYM conversion consistently through the program:
 
  To be concise, in Universe, for any internal date, D, the internal form of
 the last day of the month is:
 
  lastdayofmonth = iconv(oconv(iconv(oconv( D, 'DMY'), 'DMY') +31
  ,'DMY'),'DMY') -1
 
  DYM would work as well.
 
  Rick Nuckolls
  Lynden Inc
 
  Doesn't work on my system Anthony.
  The This month o gives the month and year ok but the attempt to iconv
  that sets it to zero, it doesn't pad the 01 into it or something so
  i just get 31 at that point.
 
  I think you were expecting that it would take 12 2011 and make it
  into 12 01 2011 or whatever but it's not working
 
 
 
 
  -Original Message-
  From: George Gallenggal...@wyanokegroup.com
  To: U2 Users 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...@listserver.u2ug.org
  [mailto:u2-users-boun...@listserver.u2ug.org]
  n 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 date, is the calendar end of month date not
  some crewy business date) Hmmm... no-one seems to have done my
  approach ...
  TODAY = @DATE
  HIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off EXT.MONTH.I =
  ICONV( THIS.MONTH.O, D) + 31 ;* random day next month
 EXT.MONTH.O =
  OCONV( NEXT.MONTH.I, DMY) ;* strip day off AST.DAY.I = ICONV(
  NEXT.MONTH.O, D) - 1 ;* subract one day If you don't have a day in
  your i/oconv it defaults to 1, so the logic orks. Unfortunately you
  can't combine the first three lines because here's no number you can
  pick that will guarantee to land you in next onth whatever today's
  date :-( Cheers, ol
 __
  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
  ___
  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

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[4,2]'):'-01','D-YMD[4,2,2')-
 1,'D-YMD[4,2,2]')
 
 
  -Original Message-
  From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-
  boun...@listserver.u2ug.org] On Behalf Of Israel, John R.
  Sent: Tuesday, 6 December 2011 10:29 a.m.
  To: 'U2 Users 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
  Fax: 937-865-9182
 
  johnisr...@daytonsuperior.com
 
  This message w/attachments (message) is intended solely for the use of
  the intended recipient(s) and may contain information that is
  privileged, confidential or proprietary. If you are not an intended
  recipient, please notify the sender, and then please delete and
  destroy all copies and attachments, and be advised that any review or
  dissemination of, or the taking of any action in reliance on, the
  information contained in or attached to this message is prohibited.
 
 
 
 
  -Original Message-
  From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-
  boun...@listserver.u2ug.org] On Behalf 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 31, 32, etc.
  will bite you sooner or later (well, it worked at my last job).
 
  Regards,
 
  Charlie Noah
  Charles W. Noah Associates
  cwn...@comcast.net
 
  http://www.linkedin.com/in/charlienoah
 
  The views and opinions expressed herein are my own (Charlie Noah) and
  do not necessarily reflect the views, positions or policies of any of
  my former, current or future employers, employees, clients, friends,
  enemies or anyone else who might take exception to them.
 
 
  On 12-05-2011 3:12 PM, Rick Nuckolls wrote:
   I think that with a slight modification, adding 31 works reasonably well.
  
   Just use the DYM conversion consistently through the program:
  
   To be concise, in Universe, for any internal date, D, the internal
   form of
  the last day of the month is:
  
   lastdayofmonth = iconv(oconv(iconv(oconv( D, 'DMY'), 'DMY') +31
   ,'DMY'),'DMY') -1
  
   DYM would work as well.
  
   Rick Nuckolls
   Lynden Inc
  
   Doesn't work on my system Anthony.
   The This month o gives the month and year ok but the attempt to
   iconv that sets it to zero, it doesn't pad the 01 into it or
   something so i just get 31 at that point.
  
   I think you were expecting that it would take 12 2011 and make it
   into 12 01 2011 or whatever but it's not working
  
  
  
  
   -Original Message-
   From: George Gallenggal...@wyanokegroup.com
   To: U2 Users 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...@listserver.u2ug.org
   [mailto:u2-users-boun...@listserver.u2ug.org]
   n 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 date, is the calendar end of month date
   not some crewy business date) Hmmm... no-one seems to have done
 my
   approach ...
   TODAY = @DATE
   HIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off EXT.MONTH.I =
   ICONV( THIS.MONTH.O, D) + 31 ;* random day next month
  EXT.MONTH.O =
   OCONV( NEXT.MONTH.I, DMY) ;* strip day off AST.DAY.I = ICONV(
   NEXT.MONTH.O, D) - 1 ;* subract one day If you don't have a day
   in your i/oconv it defaults to 1, so the logic orks. Unfortunately
   you can't combine the first three lines because here's no number
   you can pick that will guarantee to land you in next onth whatever
   today's date :-( Cheers, ol
  __
   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

Re: [U2] End of Month date routine

2011-12-05 Thread Wjhonson

Actually maybe I was trying to be too terse.
I see that putting the semicolon within an If Then Else could possibly confuse 
the compiler as it's a bit ambiguous
How about this?

   MONTH = OCONV(DATE(),'DM') ; YEAR = OCONV(DATE(),'DY')
   IF MONTH = 12 THEN
  MONTH = 1 ; YEAR += 1
   END ELSE MONTH += 1
   FIRST.OF.MONTH = ICONV(MONTH:/01/:YEAR,'D')
   END.OF.MONTH.DATE = FIRST.OF.MONTH-1










-Original Message-
From: Colin Alfke alfke...@hotmail.com
To: 'U2 Users List' u2-users@listserver.u2ug.org
Sent: Mon, Dec 5, 2011 12:50 pm
Subject: Re: [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 to it.
hth
olin
algary, Canada
-Original Message-
rom: 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 point of line 3 is for clarity so the next programmer doesn't stare
t this for ten minutes going WTH?
ou could combine 3 and 4 into a single line
ND.OF.MONTH.DATE = ICONV(MONTH:'/01/':YEAR,'D')-1

__
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


Re: [U2] End of Month date routine

2011-12-05 Thread Wjhonson

Marco, this is absolutely brilliant.
And I reserve the use of the word brilliant, for code that truly transcends 
normal space-time
I'm not certain that the use of DD is vendor independent, but it could be 
made so, by merely using OCONV(TODAY, 'DD') instead



-Original Message-
From: 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, 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
 but the attempt to iconv that sets it to zero, it doesn't pad the 01 into it 
r something
 so i just get 31 at that point.
 
 I think you were expecting that it would take 12 2011 and make it into 12 
1 2011 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 you 
 arch, backing up
 Will give you 02/xx (28 or 29)?
 George
 -Original Message-
 rom: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] 
 n 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 date, is the calendar end of month date not some 
 crewy business date)
 Hmmm... no-one seems to have done my approach ...
 TODAY = @DATE
 HIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off
 EXT.MONTH.I = ICONV( THIS.MONTH.O, D) + 31 ;* random day next month
 EXT.MONTH.O = OCONV( NEXT.MONTH.I, DMY) ;* strip day off
 AST.DAY.I = ICONV( NEXT.MONTH.O, D) - 1 ;* subract one day
 If you don't have a day in your i/oconv it defaults to 1, so the logic 
 orks. Unfortunately you can't combine the first three lines because 
 here's no number you can pick that will guarantee to land you in next 
 onth whatever today's date :-(
 Cheers,
 ol
 __
 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
  
__
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


Re: [U2] End of Month date routine

2011-12-05 Thread Wjhonson

I changed Marco's code slightly using Oconv to make it more clear what DD is 
doing and make it more generic
I'm also adding 40 instead of 32 to make it clear that we don't care how much 
we are adding as long as it's between 32 and 57
To make it clear what this is doing, we are taking the internal date, and 
subtracting from that the day number on which we are running.
This will *always* give you the last day of the previous month.  Always.
Then we add enough to jump us into the next month anywhere, doesn't matter at 
all.
And then do the same trick again, which will *always* give you the last day of 
the month in which you are running
This is a fantastic bit of magic.


   TODAY = DATE() ; LAST.MO.END = TODAY - OCONV(TODAY,'DD')
   A.DAY.NEXT.MO = LAST.MO.END + 40
   END.OF.MO.DATE = A.DAY.NEXT.MO - OCONV(A.DAY.NEXT.MO,'DD')




-Original Message-
From: 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 is vendor independent, but it could be made 
o, by merely using OCONV(TODAY, 'DD') instead

-Original Message-
rom: Marco Antonio Rojas Castro marco_roja...@hotmail.com
o: u2-users u2-users@listserver.u2ug.org
ent: Mon, Dec 5, 2011 12:49 pm
ubject: Re: [U2] End of Month date routine

ODAY = DATE()
M = TODAY - TODAYDD + 32
M = 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
but the attempt to iconv that sets it to zero, it doesn't pad the 01 into it 
 something
so i just get 31 at that point.

I think you were expecting that it would take 12 2011 and make it into 12 
 2011 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 you 
 arch, backing up
Will give you 02/xx (28 or 29)?
George
-Original Message-
rom: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] 
 n 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 date, is the calendar end of month date not some 
crewy business date)
Hmmm... no-one seems to have done my approach ...
TODAY = @DATE
HIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off
EXT.MONTH.I = ICONV( THIS.MONTH.O, D) + 31 ;* random day next month
EXT.MONTH.O = OCONV( NEXT.MONTH.I, DMY) ;* strip day off
AST.DAY.I = ICONV( NEXT.MONTH.O, D) - 1 ;* subract one day
If you don't have a day in your i/oconv it defaults to 1, so the logic 
orks. Unfortunately you can't combine the first three lines because 
here's no number you can pick that will guarantee to land you in next 
onth whatever today's date :-(
Cheers,
ol
__
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
  
_
-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

___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] End of Month date routine

2011-12-05 Thread Wols Lists

On 05/12/11 20:10, George Gallen wrote:

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)?


Others have picked up on it, but if today is 31/1 :-) the first 
conversion gives us Jan 20XX *before* adding the 31. If the iconv then 
works as I expect (from what others have said, maybe it only works in 
INFORMATION flavour?) this then gives us 1st Feb, before subtracting 1 
to give us 31st Jan as the last day of the current (Jan) month.


Cheers,
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 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 = @DATE
THIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off
NEXT.MONTH.I = ICONV( THIS.MONTH.O, D) + 31 ;* random day next month
NEXT.MONTH.O = OCONV( NEXT.MONTH.I, DMY) ;* strip day off
LAST.DAY.I = ICONV( NEXT.MONTH.O, D) - 1 ;* subract one day

If you don't have a day in your i/oconv it defaults to 1, so the logic
works. Unfortunately you can't combine the first three lines because
there's no number you can pick that will guarantee to land you in next
month whatever today's date :-(

Cheers,
Wol
___
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


Re: [U2] End of Month date routine

2011-12-05 Thread Wols Lists

On 05/12/11 22:37, Wols Lists wrote:

On 05/12/11 20:10, George Gallen wrote:

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)?


Others have picked up on it, but if today is 31/1 :-) the first
conversion gives us Jan 20XX *before* adding the 31. If the iconv then
works as I expect (from what others have said, maybe it only works in
INFORMATION flavour?) this then gives us 1st Feb, before subtracting 1
to give us 31st Jan as the last day of the current (Jan) month.

Cheers,
Wol


Replying to myself, as others have pointed out the bug in my original 
code was using DMY for the oconv, but just D for the iconv.


Assuming 31/01/2011, the oconv DMY will return 01/11 (jan 2011) but the 
iconv D will mis-interpret it as 01/11/11 (1st Nov 2011) :-(


So fixing my code to use DMY everywhere should work.

Cheers,
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 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 = @DATE
THIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off
NEXT.MONTH.I = ICONV( THIS.MONTH.O, D) + 31 ;* random day next month
NEXT.MONTH.O = OCONV( NEXT.MONTH.I, DMY) ;* strip day off
LAST.DAY.I = ICONV( NEXT.MONTH.O, D) - 1 ;* subract one day

If you don't have a day in your i/oconv it defaults to 1, so the logic
works. Unfortunately you can't combine the first three lines because
there's no number you can pick that will guarantee to land you in next
month whatever today's date :-(

Cheers,
Wol
___
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


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

SUBROUTINE GET.EOM(IDAY)
*IDAY = DATE()
THIS = OCONV(IDAY,'DM')
LOOP
  IDAY += 1
UNTIL OCONV(IDAY,'DM') NE THIS REPEAT
IDAY -= 1
RETURN


Code snippets are fun - copyright not so much.

Regards, Keith


___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] End of Month date routine

2011-12-05 Thread Rick Nuckolls
Just for laughs, the following works with only a single date conversion, though 
I will admit that it gets a little too obscure to be considered maintainable.  
Admittedly, there are probably easier ways to tell how many days there are in a 
month, but they may not be as much fun!

Rick Nuckolls
Lynden Inc


 extdate = oconv( d, 'D4-YMD’)

 year = field(extdate, '-',1)
 month = field( extdate, '-', 2)
 dom = field(extdate,'-',3)

 if month = 2 then
daysinmonth = 28 + ( not(mod(year,4))  ( mod(year,100) ! 
not(mod(year,400)) ))
 end else
daysinmonth = 30 + mod( if month  8 then abs(month-2) else 
month-7, 2)
 end

 lastdayofmonth = d - dom + daysinmonth


On Dec 5, 2011, at 2:26 PM, Wjhonson wrote:

 
 I changed Marco's code slightly using Oconv to make it more clear what DD is 
 doing and make it more generic
 I'm also adding 40 instead of 32 to make it clear that we don't care how much 
 we are adding as long as it's between 32 and 57
 To make it clear what this is doing, we are taking the internal date, and 
 subtracting from that the day number on which we are running.
 This will *always* give you the last day of the previous month.  Always.
 Then we add enough to jump us into the next month anywhere, doesn't matter at 
 all.
 And then do the same trick again, which will *always* give you the last day 
 of the month in which you are running
 This is a fantastic bit of magic.
 
 
   TODAY = DATE() ; LAST.MO.END = TODAY - OCONV(TODAY,'DD')
   A.DAY.NEXT.MO = LAST.MO.END + 40
   END.OF.MO.DATE = A.DAY.NEXT.MO - OCONV(A.DAY.NEXT.MO,'DD')
 
 
 
 
 -Original Message-
 From: 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 is vendor independent, but it could be 
 made 
 o, by merely using OCONV(TODAY, 'DD') instead
 
 -Original Message-
 rom: Marco Antonio Rojas Castro marco_roja...@hotmail.com
 o: u2-users u2-users@listserver.u2ug.org
 ent: Mon, Dec 5, 2011 12:49 pm
 ubject: Re: [U2] End of Month date routine
 
 ODAY = DATE()
 M = TODAY - TODAYDD + 32
 M = 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
 but the attempt to iconv that sets it to zero, it doesn't pad the 01 into 
 it 
 something
 so i just get 31 at that point.
 
 I think you were expecting that it would take 12 2011 and make it into 12 
 2011 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 
 you 
 arch, backing up
 Will give you 02/xx (28 or 29)?
 George
 -Original Message-
 rom: u2-users-boun...@listserver.u2ug.org 
 [mailto:u2-users-boun...@listserver.u2ug.org] 
 n 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 date, is the calendar end of month date not some 
 crewy business date)
 Hmmm... no-one seems to have done my approach ...
 TODAY = @DATE
 HIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off
 EXT.MONTH.I = ICONV( THIS.MONTH.O, D) + 31 ;* random day next month
 EXT.MONTH.O = OCONV( NEXT.MONTH.I, DMY) ;* strip day off
 AST.DAY.I = ICONV( NEXT.MONTH.O, D) - 1 ;* subract one day
 If you don't have a day in your i/oconv it defaults to 1, so the logic 
 orks. Unfortunately you can't combine the first three lines because 
 here's no number you can pick that will guarantee to land you in next 
 onth whatever today's date :-(
 Cheers,
 ol
 __
 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
 
 _
 -Users mailing list
 -us...@listserver.u2ug.org
 tp://listserver.u2ug.org/mailman/listinfo/u2-users
 ___
 2-Users mailing list
 2-us

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 a single date conversion, though 
 will admit that it gets a little too obscure to be considered maintainable.  
dmittedly, there are probably easier ways to tell how many days there are in a 
onth, but they may not be as much fun!
Rick Nuckolls
ynden Inc

extdate = oconv( d, 'D4-YMD’)
 year = field(extdate, '-',1)
month = field( extdate, '-', 2)
dom = field(extdate,'-',3)
 if month = 2 then
   daysinmonth = 28 + ( not(mod(year,4))  ( mod(year,100) ! 
ot(mod(year,400)) ))
end else
   daysinmonth = 30 + mod( if month  8 then abs(month-2) else month-7, 
)
end
 lastdayofmonth = d - dom + daysinmonth

n Dec 5, 2011, at 2:26 PM, Wjhonson wrote:
 
 I changed Marco's code slightly using Oconv to make it more clear what DD is 
oing and make it more generic
 I'm also adding 40 instead of 32 to make it clear that we don't care how much 
e are adding as long as it's between 32 and 57
 To make it clear what this is doing, we are taking the internal date, and 
ubtracting from that the day number on which we are running.
 This will *always* give you the last day of the previous month.  Always.
 Then we add enough to jump us into the next month anywhere, doesn't matter at 
ll.
 And then do the same trick again, which will *always* give you the last day of 
he month in which you are running
 This is a fantastic bit of magic.
 
 
   TODAY = DATE() ; LAST.MO.END = TODAY - OCONV(TODAY,'DD')
   A.DAY.NEXT.MO = LAST.MO.END + 40
   END.OF.MO.DATE = A.DAY.NEXT.MO - OCONV(A.DAY.NEXT.MO,'DD')
 
 
 
 
 -Original Message-
 From: 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 is vendor independent, but it could be 
ade 
 o, by merely using OCONV(TODAY, 'DD') instead
 
 -Original Message-
 rom: Marco Antonio Rojas Castro marco_roja...@hotmail.com
 o: u2-users u2-users@listserver.u2ug.org
 ent: Mon, Dec 5, 2011 12:49 pm
 ubject: Re: [U2] End of Month date routine
 
 ODAY = DATE()
 M = TODAY - TODAYDD + 32
 M = 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
 but the attempt to iconv that sets it to zero, it doesn't pad the 01 into it 
 something
 so i just get 31 at that point.
 
 I think you were expecting that it would take 12 2011 and make it into 12 
 2011 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 you 
 arch, backing up
 Will give you 02/xx (28 or 29)?
 George
 -Original Message-
 rom: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] 
 n 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 date, is the calendar end of month date not some 
 crewy business date)
 Hmmm... no-one seems to have done my approach ...
 TODAY = @DATE
 HIS.MONTH.O = OCONV (TODAY, DMY) ;* strip day off
 EXT.MONTH.I = ICONV( THIS.MONTH.O, D) + 31 ;* random day next month
 EXT.MONTH.O = OCONV( NEXT.MONTH.I, DMY) ;* strip day off
 AST.DAY.I = ICONV( NEXT.MONTH.O, D) - 1 ;* subract one day
 If you don't have a day in your i/oconv it defaults to 1, so the logic 
 orks. Unfortunately you can't combine the first three lines because 
 here's no number you can pick that will guarantee to land you in next 
 onth whatever today's date :-(
 Cheers,
 ol
 __
 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