RE: [U2] Finding last day of month

2005-06-07 Thread Mark Baldridge
I wrote the application about 15 years ago when we were then VMark
Software.  I believe that would make it an internal IBM tool.  I have
several other performance measuring tools that I use at customer sites when
analyzing system, application, and other performance issues.

The set of tests are likely not complete, but I have several hundred tests
covering various aspects of the run machine, as well as file based
operations, overflow, oversize I/O, messaging, sockets, and the like.  I
also add tests to answer specific questions that come up during customer
sites when chasing anomalies in applications.

One of these days I will get around to compiling my customer travesl into a
performance tuning book!  Alas, it keeps finding its way to back burners.
Sigh.  Much of the material in the UniVerse Theory and Practice course came
from my publications and internal documents.  One advantage of the many
nights in hotels around the U.S. and occasionally the world, is I have the
free time to do work on these things, when not fatigued from doing it all
day at a customer site.  One of the more interesting evening projects
produced a set of programs using transaction logs for maintaining a backup
server as either a fail over machine or as a report server to offload that
kind of work from an OLTP production server.  I believe a previous poster
some months back, had mentioned doing something like that as well.

> From: "Stevenson, Charles" <[EMAIL PROTECTED]>

> Mark,
> What are these timing tests?
> They kinda look like the tool PI has.  I can almost remember the name of
> it now, but it was so long ago.
> Is this a tool we users can run or is this something internal at IBM?
> If internal, do you have a complete set of comparative speeds for the
> various operations & functions available in UV-Basic?


Mark A. Baldridge
Principal Consultant
North American Lab Services
DB2 Information Management, IBM Software Group
(607) 351-5666
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-06 Thread Stevenson, Charles
Mark,
What are these timing tests?
They kinda look like the tool PI has.  I can almost remember the name of
it now, but it was so long ago.
Is this a tool we users can run or is this something internal at IBM?
If internal, do you have a complete set of comparative speeds for the
various operations & functions available in UV-Basic?

-Original Message-
From: Mark Baldridge

The original request was for a shortest code fragment.  This likely
meant as line count, but could have been execution time.

I am using UniVerse 10.1.3 on a 1.7 GHz pentium.  Here are some current
timings.  Except for test 0001 which is an empty FOR NEXT loop, to the
left of the "|" is a hint of the initialization, and to the right is a
hint of the code under test.

An interesting result is that it is faster to assign SPACE(2) than to a
variable than assigning a 1 or 10 character string in a variable to
another variable.

The basic takeaway is that use of ICONV and OCONV should be minimized if
you optimize for time.

Test Loop Core.. (uSec) per
 Iteration.

0001 FOR/NEXT | (EMPTY)   0.081
0005 A=0  0.037
0012 |A=1+1   0.034
0050 IF (B) THEN-WIDE.IF  0.025
0051 IF (B) THEN WIDE.IF  0.031
0072 A=2;B=2|C=A*B0.033
0201 A=   10x|B=A[1,1]0.303
0221 A=SPACE(2)|A=SPACE(2)0.283
0231 A:='12345':@VM...|B=A[char(253)  0.457
 ,10,1]
0338 A='1'|B=OCONV(A,"D4/")   2.503
0352 A='1'|B=OCONV(A,"D4-YMD[4,2  2.821
 ,2]")
0353 A='1'|B=OCONV(A,"D4/");[7,4  3.986
 ]-[1,2]-[4,2]
0365 A=2;B=2|C=A/B0.042
0369 A=2|B=INT(A) 0.293
0370 A=2.2|B=INT(A)   0.294
0371 A=2000|B=MOD(A,4)0.236
0372 A=2001|B=MOD(A,4)0.238
0374 A=SPACE(1)|B=A   0.321
0375 A=SPACE(   10)|B=A   0.323
0376 A=SPACE(  100)|B=A   0.369
0377 A=SPACE( 1000)|B=A   0.559
0378 A=SPACE(1)|B=A   1.727
0385 A='20040825'|B=ICONV(A,"D4") 0.879
0386 A='13387'|B=OCONV(A,"D4")2.796
0387 A=13387|B=OCONV(A,"D4")  3.186


Mark A. Baldridge
Principal Consultant
North American Lab Services
DB2 and U2 Information Management, IBM Software Group
(508) 524-5666
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Finding last day of month

2005-06-04 Thread Mark Baldridge
The original request was for a shortest code fragment.  This likely meant
as line count, but could have been execution time.

I am using UniVerse 10.1.3 on a 1.7 GHz pentium.  Here are some current
timings.  Except for test 0001 which is an empty FOR NEXT loop, to the left
of the "|" is a hint of the initialization, and to the right is a hint of
the code under test.

An interesting result is that it is faster to assign SPACE(2) than to a
variable than assigning a 1 or 10 character string in a variable to another
variable.

The basic takeaway is that use of ICONV and OCONV should be minimized if
you optimize for time.

Test Loop Core.. (uSec) per
 Iteration.

0001 FOR/NEXT | (EMPTY)   0.081
0005 A=0  0.037
0012 |A=1+1   0.034
0050 IF (B) THEN-WIDE.IF  0.025
0051 IF (B) THEN WIDE.IF  0.031
0072 A=2;B=2|C=A*B0.033
0201 A=   10x|B=A[1,1]0.303
0221 A=SPACE(2)|A=SPACE(2)0.283
0231 A:='12345':@VM...|B=A[char(253)  0.457
 ,10,1]
0338 A='1'|B=OCONV(A,"D4/")   2.503
0352 A='1'|B=OCONV(A,"D4-YMD[4,2  2.821
 ,2]")
0353 A='1'|B=OCONV(A,"D4/");[7,4  3.986
 ]-[1,2]-[4,2]
0365 A=2;B=2|C=A/B0.042
0369 A=2|B=INT(A) 0.293
0370 A=2.2|B=INT(A)   0.294
0371 A=2000|B=MOD(A,4)0.236
0372 A=2001|B=MOD(A,4)0.238
0374 A=SPACE(1)|B=A   0.321
0375 A=SPACE(   10)|B=A   0.323
0376 A=SPACE(  100)|B=A   0.369
0377 A=SPACE( 1000)|B=A   0.559
0378 A=SPACE(1)|B=A   1.727
0385 A='20040825'|B=ICONV(A,"D4") 0.879
0386 A='13387'|B=OCONV(A,"D4")2.796
0387 A=13387|B=OCONV(A,"D4")  3.186


Mark A. Baldridge
Principal Consultant
North American Lab Services
DB2 and U2 Information Management, IBM Software Group
(508) 524-5666
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-03 Thread Bob Witney
i've not read this entire thread so someone may have said this  but i get the 
first day of the next month and then -1
 
works a treat

-Original Message- 
From: [EMAIL PROTECTED] on behalf of Marco Manyevere 
Sent: Fri 03/06/2005 09:40 
To: u2-users@listserver.u2ug.org 
Cc: 
Subject: Re: [U2] Finding last day of month



Will,

This was exactly my method, except I was adding 35 days (it could have 
been 30 as well) to the first day of the month to get to next month.

I also dislike the lookup table idea  i.e. 31,28,30,31,etc, the leap 
year or 12th month logic.

Thanks for all the responses guys.

[EMAIL PROTECTED] wrote:
Ok smartass you say let's see you do it 

First of all, you can always get from the month you are in, to the next 
month
by simply add 30 days to the middle of the month. And you never need to
worry about leap years nor about 12th month logic

Input Date ; * format mmdd
Middleofthismonth = date[1,6]:'15'
I.Middle = Iconv(Middleofthismonth,'D')
I.Next = I.Middle + 30
NextMonth = Oconv(I.NEXT,'D2-')
FirstDayNextMonth = NextMonth[1,2]:'01':NextMonth[5,2]
I.FirstDay = Iconv(FirstDayNextMonth,'D')
I.LastDayPreviousMonth = I.FirstDay - 1

Now can we scrunch this down?
Input Date ; *format mmdd
NextMonth = Oconv(Iconv(date[1,6]:'15','D') + 30,'D2')
I.LastDayPreviousMonth = Iconv(NextMonth[1,2]:'01':NextMonth[5,2],'D') 
+ 1

Do I win the big stuffed pickle?
Will Johnson
Fast Forward Technologies
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

   
-
Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with 
voicemail
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
__



__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__

[demime 1.01d removed an attachment of type application/ms-tnef which had a 
name of winmail.dat]
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Finding last day of month

2005-06-03 Thread Moderator
All,
The "Play Date" has been moved to the U2-Community.

- Charles Barouch, Moderator

To sign up for U2-Community or any of our other lists:

   1. U2-Users
   2. U2-Community
   3. RBSolutions
   4. SBSolutions
   5. U2-Users Digest
   6. U2-Community Digest
   7. RBSolutions Digest
   8. SBSolutions Digest

Please visit http://listserver.u2ug.org/, enter your e-mail address, and 
'browse all' lists to maintain your access.

 - Charles Barouch
 Moderator
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Finding last day of month

2005-06-03 Thread Marco Manyevere
Will,
 
This was exactly my method, except I was adding 35 days (it could have been 30 
as well) to the first day of the month to get to next month.
 
I also dislike the lookup table idea  i.e. 31,28,30,31,etc, the leap year or 
12th month logic.
 
Thanks for all the responses guys.

[EMAIL PROTECTED] wrote:
Ok smartass you say let's see you do it 

First of all, you can always get from the month you are in, to the next month 
by simply add 30 days to the middle of the month. And you never need to 
worry about leap years nor about 12th month logic

Input Date ; * format mmdd
Middleofthismonth = date[1,6]:'15'
I.Middle = Iconv(Middleofthismonth,'D')
I.Next = I.Middle + 30
NextMonth = Oconv(I.NEXT,'D2-')
FirstDayNextMonth = NextMonth[1,2]:'01':NextMonth[5,2]
I.FirstDay = Iconv(FirstDayNextMonth,'D')
I.LastDayPreviousMonth = I.FirstDay - 1

Now can we scrunch this down?
Input Date ; *format mmdd
NextMonth = Oconv(Iconv(date[1,6]:'15','D') + 30,'D2')
I.LastDayPreviousMonth = Iconv(NextMonth[1,2]:'01':NextMonth[5,2],'D') + 1

Do I win the big stuffed pickle?
Will Johnson
Fast Forward Technologies
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


-
Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Finding last day of month

2005-06-03 Thread Stuart . Boydell
> But your's takes more CPU cycles so there :)
> Smaller in opcode? or smaller in milliseconds?
> Ah

Yeah, but now that you've challenged me, this one's smaller in size, op 
codes and presumably cpu.

   input oDate ; *format mmdd
   lastDayOfMonth = 
oconv(iconv(oconv(iconv(oDate,'ml#6':@vm:'dym')+31,'dym'),'dym')-1,'dymd[4"",2""]')

S




**
This email message and any files transmitted with it are confidential
and intended solely for the use of addressed recipient(s). If you have 
received this email in error please notify the Spotless IS Support Centre (61 3 
9269 7555) immediately who will advise further action.

This footnote also confirms that this email message has been scanned
for the presence of computer viruses.
**
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Finding last day of month

2005-06-02 Thread FFT2001
In a message dated 6/2/2005 8:17:25 PM Pacific Daylight Time, 
[EMAIL PROTECTED] writes:


> That's an interesting approach, but it comes at the price of an extra 
> ICONV, which is more expensive than a simple IF statement.  Granted, the 
> difference isn't significant for a small number of invocations, but after 
> a while it adds up.

I just hate "special logic" like 
If its the 12th month
If its a leap year
If its year 1999 or  
I just find it more pure to use the internal system information to calculate 
all that.

Will Johnson
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Finding last day of month

2005-06-02 Thread FFT2001
In a message dated 6/2/2005 9:40:08 PM Pacific Daylight Time, 
[EMAIL PROTECTED] writes:


> [EMAIL PROTECTED]  wrote on 06/02/2005 10:34:09 PM:
> 
> > input oDate ; *format mmdd
> > iDate = iconv(oDate,'dymd')
> > loop until oconv(iDate+1,'dd) = 1 do iDate += 1 repeat
> > lastDay = oconv(iDate,'dymd')
> > 
> > Not sure if it's worth bragging about - but mine's smaller (146 v. 161 
> > bytes).

But your's takes more CPU cycles so there :)
Smaller in opcode? or smaller in milliseconds?
Ah
Will
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Anthony Grant
Oh please, Kieran. That's overboard.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Kieran Clulow
Sent: Friday, 3 June 2005 11:43 AM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Finding last day of month

... or as a one line coding horror ;)

1   LAST.DAY =
REPLACE(CHANGE('31,28,31,30,31,30,31,31,30,31,30,31',',',@AM),2;28+(NOT(MOD((
THISDATE[1,4]),4)) AND (NOT(MOD((THISDATE[1,4]),400)) OR
MOD((THISDATE[1,4]),100<(THISDATE[5,2]+0)>
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Finding last day of month

2005-06-02 Thread Timothy Snyder
[EMAIL PROTECTED]  wrote on 06/02/2005 10:34:09 PM:

> input oDate ; *format mmdd
> iDate = iconv(oDate,'dymd')
> loop until oconv(iDate+1,'dd) = 1 do iDate += 1 repeat
> lastDay = oconv(iDate,'dymd')
> 
> Not sure if it's worth bragging about - but mine's smaller (146 v. 161 
> bytes).

This will chew a lot of CPU cycles if you're working on the beginning of 
the month.  Again, it doesn't make much of a difference on a small data 
sample, but if you're processing millions of records, it can add up.

OK, I'll get off my performance soapbox now...


Tim Snyder
Consulting I/T Specialist , U2 Professional Services
North American Lab Services
DB2 Information Management, IBM Software Group
[EMAIL PROTECTED]
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Allen E. Elwood
Gee guys, mine was 4 lines.  I think the request was for the 'shortest'...

:-)

Now, who's gonna put all these routines through a speed test to find out
which is the most efficient?

Me, I'm going back to watching Kull the conqueror

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED]
Sent: Thursday, June 02, 2005 7:46 PM
To: u2-users@listserver.u2ug.org
Subject: Re: [U2] Finding last day of month


In a message dated 6/2/05 7:07:42 PM Pacific Daylight Time, [EMAIL PROTECTED]
writes:

<< Input Date ; * format mmdd
 Middleofthismonth = date[1,6]:'15'
 I.Middle = Iconv(Middleofthismonth,'D')
 I.Next = I.Middle + 30
 NextMonth = Oconv(I.NEXT,'D2-')
 FirstDayNextMonth = NextMonth[1,2]:'01':NextMonth[5,2]
 I.FirstDay = Iconv(FirstDayNextMonth,'D')
 I.LastDayPreviousMonth = I.FirstDay - 1

 Now can we scrunch this down?
 Input Date ; *format mmdd
 NextMonth = Oconv(Iconv(date[1,6]:'15','D') + 30,'D2')
 I.LastDayPreviousMonth = Iconv(NextMonth[1,2]:'01':NextMonth[5,2],'D') + 1
>>

Before I get jumped on, there is an error in the above
 Input Date ; * format mmdd
 Middleofthismonth = date[1,6]:'15'
 I.Middle = Iconv(Middleofthismonth,'D')

Should be changed to
 Input Date ; * format mmdd
 Middleofthismonth = date[5,2]:'-15-':date[1,4]
 I.Middle = Iconv(Middleofthismonth,'D')

and then
 NextMonth = Oconv(Iconv(date[1,6]:'15','D') + 30,'D2')
should be changed to
 NextMonth = Oconv(Iconv(date[5,2]:'-15-':date[1,4], 'D') + 30,'D2')

Will Johnson
Fast Forward Technologies
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Finding last day of month

2005-06-02 Thread Timothy Snyder
[EMAIL PROTECTED] wrote on 06/02/2005 09:54:59 PM:

> Input Date ; *format mmdd
> NextMonth = Oconv(Iconv(date[1,6]:'15','D') + 30,'D2')
> I.LastDayPreviousMonth = Iconv(NextMonth[1,2]:'01':NextMonth[5,2],'D') + 
1

That's an interesting approach, but it comes at the price of an extra 
ICONV, which is more expensive than a simple IF statement.  Granted, the 
difference isn't significant for a small number of invocations, but after 
a while it adds up.

By the way, you may want to check the logic of the scrunched version. It's 
not giving you what you want.
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Finding last day of month

2005-06-02 Thread FFT2001
In a message dated 6/2/05 7:07:42 PM Pacific Daylight Time, [EMAIL PROTECTED] 
writes:

<< Input Date ; * format mmdd
 Middleofthismonth = date[1,6]:'15'
 I.Middle = Iconv(Middleofthismonth,'D')
 I.Next = I.Middle + 30
 NextMonth = Oconv(I.NEXT,'D2-')
 FirstDayNextMonth = NextMonth[1,2]:'01':NextMonth[5,2]
 I.FirstDay = Iconv(FirstDayNextMonth,'D')
 I.LastDayPreviousMonth = I.FirstDay - 1
 
 Now can we scrunch this down?
 Input Date ; *format mmdd
 NextMonth = Oconv(Iconv(date[1,6]:'15','D') + 30,'D2')
 I.LastDayPreviousMonth = Iconv(NextMonth[1,2]:'01':NextMonth[5,2],'D') + 1 >>

Before I get jumped on, there is an error in the above
 Input Date ; * format mmdd
 Middleofthismonth = date[1,6]:'15'
 I.Middle = Iconv(Middleofthismonth,'D')

Should be changed to
 Input Date ; * format mmdd
 Middleofthismonth = date[5,2]:'-15-':date[1,4]
 I.Middle = Iconv(Middleofthismonth,'D')

and then
 NextMonth = Oconv(Iconv(date[1,6]:'15','D') + 30,'D2')
should be changed to
 NextMonth = Oconv(Iconv(date[5,2]:'-15-':date[1,4], 'D') + 30,'D2')

Will Johnson
Fast Forward Technologies
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Finding last day of month

2005-06-02 Thread Stuart . Boydell
[EMAIL PROTECTED] wrote on 03-06-2005 12.54.59:
> 
> Now can we scrunch this down?
> Input Date ; *format mmdd
> NextMonth = Oconv(Iconv(date[1,6]:'15','D') + 30,'D2')
> I.LastDayPreviousMonth = Iconv(NextMonth[1,2]:'01':NextMonth[5,2],'D') + 
1


input oDate ; *format mmdd
iDate = iconv(oDate,'dymd')
loop until oconv(iDate+1,'dd) = 1 do iDate += 1 repeat
lastDay = oconv(iDate,'dymd')

Not sure if it's worth bragging about - but mine's smaller (146 v. 161 
bytes).
S


**
This email message and any files transmitted with it are confidential
and intended solely for the use of addressed recipient(s). If you have 
received this email in error please notify the Spotless IS Support Centre (61 3 
9269 7555) immediately who will advise further action.

This footnote also confirms that this email message has been scanned
for the presence of computer viruses.
**
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Finding last day of month

2005-06-02 Thread FFT2001
Ok smartass you say let's see you do it 

First of all, you can always get from the month you are in, to the next month 
by simply add 30 days to the middle of the month.  And you never need to 
worry about leap years nor about 12th month logic

Input Date ; * format mmdd
Middleofthismonth = date[1,6]:'15'
I.Middle = Iconv(Middleofthismonth,'D')
I.Next = I.Middle + 30
NextMonth = Oconv(I.NEXT,'D2-')
FirstDayNextMonth = NextMonth[1,2]:'01':NextMonth[5,2]
I.FirstDay = Iconv(FirstDayNextMonth,'D')
I.LastDayPreviousMonth = I.FirstDay - 1

Now can we scrunch this down?
Input Date ; *format mmdd
NextMonth = Oconv(Iconv(date[1,6]:'15','D') + 30,'D2')
I.LastDayPreviousMonth = Iconv(NextMonth[1,2]:'01':NextMonth[5,2],'D') + 1

Do I win the big stuffed pickle?
Will Johnson
Fast Forward Technologies
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Kieran Clulow
... or as a one line coding horror ;)

1   LAST.DAY =
REPLACE(CHANGE('31,28,31,30,31,30,31,31,30,31,30,31',',',@AM),2;28+(NOT(MOD((
THISDATE[1,4]),4)) AND (NOT(MOD((THISDATE[1,4]),400)) OR
MOD((THISDATE[1,4]),100<(THISDATE[5,2]+0)>
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Finding last day of month

2005-06-02 Thread FFT2001


People!  use the system why are you doing all this math in your program?  The 
system knows what years are leap and what aren't.  Let it do the work for you!



Will Johnson
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Finding last day of month

2005-06-02 Thread FFT2001
Add of you who are doing special logic on month 12 are FIRED!

Will Johnson
Fast Forward Technologies
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Kieran Clulow
That incorrectly thinks 2100 is a leap.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ross Morrissey
Sent: Friday, 3 June 2005 10:15 AM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Finding last day of month

Aiming for SHORT (not clean, clear, or any of that other good stuff):

PRINT "D": ; INPUT D
PRINT D[1,6]:MOD(D[5,2]+D[5,2]>7,2)+30-(D[5,2]=2)*(2-MOD(D[1,4],4)#0)

D?20040203
20040229
D?20030303
20030331

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Marco Manyevere
Sent: Thursday, June 02, 2005 10:31 AM
To: u2-users@listserver.u2ug.org
Subject: [U2] Finding last day of month
 
Given a date like 20040203, I want to return the last valid date for that
month and year (20040229 in this case). What is the shortest code fragment
to achieve this?
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Kieran Clulow


YEAR = THISDATE[1,4] ; MONTH = THISDATE[5,2]+0
DAYS = CHANGE('31,28,31,30,31,30,31,31,30,31,30,31',',',@AM)
DAYS<2> += (NOT(MOD(YEAR,4)) AND (NOT(MOD(YEAR,400)) OR MOD(YEAR,100)))
LAST.DATE = DAYS

Should catch everything.

Kieran.
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Ross Morrissey
Aiming for SHORT (not clean, clear, or any of that other good stuff):

PRINT "D": ; INPUT D
PRINT D[1,6]:MOD(D[5,2]+D[5,2]>7,2)+30-(D[5,2]=2)*(2-MOD(D[1,4],4)#0)

D?20040203
20040229
D?20030303
20030331

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Marco Manyevere
Sent: Thursday, June 02, 2005 10:31 AM
To: u2-users@listserver.u2ug.org
Subject: [U2] Finding last day of month
 
Given a date like 20040203, I want to return the last valid date for that
month and year (20040229 in this case). What is the shortest code fragment
to achieve this?
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Bruce Nichol

Oh dear, Oh dear!

What ever happend to :
DATE = ''
FOR I = 31 TO 28 STEP -1
  IF OCONV(ICONV(I:rest of date,'D'),'D') = I:rest of date THEN
DATE = I:rest of date
EXIT
  END
NEXT I
IF DATE = '' THEN Come to screeching HALT

Of course for the people with backward dates (!!!), the "I:rest of date" 
would look like MONTH:I:YEAR with the appropriate separators, wouldn't it


At 17:01 02/06/05 -0400, you wrote:


I use the method my dad taught me when I was a kid, cuz I couldn't
remember "Thiry days hath September...".

Hold 2 fists side-by-side, forefingers of right & left hand touching.
Each knuckle and each valley between knuckles represents a month.
Start at the left pinky knuckle and count off months.
If a month lands on a knuckle, it has 31 days.
If it lands on a valley, it has 30 days. (Except February has that 28/29
thing going on.)


   _   _   _   _  _   _   _   _
  /J\_/M\_/M\_/J\/A\_/O\_/D\_/ \
  |  F   A   J  ||  S   N  |
  | || |
  | || |
  \ / \/
   \   /   \  /
|  left   | | right  |
|  fist   | |  fist  |
  view from top

QED
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.5.0 - Release Date: 02/06/05




--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.5.0 - Release Date: 02/06/05


Regards,

Bruce Nichol
Talon Computer Services
ALBURYNSW 2640
Australia

http://www.taloncs.com.au

Tel: +61 (0)411149636
Fax: +61 (0)260232119

If it ain't broke, fix it till it is! 



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.5.0 - Release Date: 02/06/05
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Marilyn Hilb
Program that! 

Works with one hand too. Just hit the last knuckle a 2nd time before heading 
back. Easier to have 1 hand for pointing, pencil in the mouth to point marks up 
my hands. I was also taught this someplace along the line, and still use this 
method to this day.  


 -Original Message-
From:   Stevenson, Charles [mailto:[EMAIL PROTECTED] 
Sent:   Thursday, June 02, 2005 4:02 PM
To: u2-users@listserver.u2ug.org
Subject:RE: [U2] Finding last day of month

I use the method my dad taught me when I was a kid, cuz I couldn't
remember "Thiry days hath September...".

Hold 2 fists side-by-side, forefingers of right & left hand touching.
Each knuckle and each valley between knuckles represents a month.
Start at the left pinky knuckle and count off months.
If a month lands on a knuckle, it has 31 days.
If it lands on a valley, it has 30 days. (Except February has that 28/29
thing going on.)


   _   _   _   _  _   _   _   _  
  /J\_/M\_/M\_/J\/A\_/O\_/D\_/ \ 
  |  F   A   J  ||  S   N  | 
  | || | 
  | || | 
  \ / \/ 
   \   /   \  /  
|  left   | | right  |   
|  fist   | |  fist  |   
  view from top

QED
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Stevenson, Charles
I use the method my dad taught me when I was a kid, cuz I couldn't
remember "Thiry days hath September...".

Hold 2 fists side-by-side, forefingers of right & left hand touching.
Each knuckle and each valley between knuckles represents a month.
Start at the left pinky knuckle and count off months.
If a month lands on a knuckle, it has 31 days.
If it lands on a valley, it has 30 days. (Except February has that 28/29
thing going on.)


   _   _   _   _  _   _   _   _  
  /J\_/M\_/M\_/J\/A\_/O\_/D\_/ \ 
  |  F   A   J  ||  S   N  | 
  | || | 
  | || | 
  \ / \/ 
   \   /   \  /  
|  left   | | right  |   
|  fist   | |  fist  |   
  view from top

QED
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Allen E. Elwood
Mongo only small pawn in game of leap years

I'm sure by then all of my code will be obsolete and that the technology
that replaces computers will be beyond anything I can even imagine

I read somewhere that some smart guy figured out how to transport a photon
and one of the possible applications will be a zero wait state memory
device.  Beam me up Scotty!

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Richard A.
Wilson
Sent: Thursday, June 02, 2005 1:38 PM
To: u2-users@listserver.u2ug.org
Subject: Re: [U2] Finding last day of month


2100 & 2300 aren't leap years. I guess it depends on the application,
antiques,
historical dates etc.

or future dates like when you will be fully vested in your retirement acct.

 Rich

Allen E. Elwood wrote:

> So...it won't be a problem until 2,400?  I can live with that.  And I'm
> gettin' up there in my years too.  Just turned 49 last March.
>
>
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Richard A.
> Wilson
> Sent: Thursday, June 02, 2005 12:29 PM
> To: u2-users@listserver.u2ug.org
> Subject: Re: [U2] Finding last day of month
>
>
> you cant just use mod(x,4) logic
>
> the following from some website (dont remember where/when I found it)
> ***
> The rule for leap years is that all years divisable by 4 are leap years,
> except
> those years divisable by 100. The exception is that years divisible by 400
> are
> leap years
> 
> of course only us old foggies that used pick way back when remember this

>
> Rich
>
> Allen E. Elwood wrote:
>
>
>>I've always used the simple method.
>>
>>*Initialization section
>>END.DATES = '31,28,31,30,31,30,31,31,30,31,30,31'
>>END.DATES = CHANGE(END.DATES,',',@AM)
>>
>>*Main loop section
>>LAST.DATE = END.DATES
>>IF MONTH = 2 AND NOT(MOD(YEAR,4)) THEN LAST.DATE+=1
>>
>>btw, there may be an error in this, my allergies are truly messing with my
>>head today.and for the last weekGaaa
>>
>>Allen
>>
>>-Original Message-
>>From: [EMAIL PROTECTED]
>>[mailto:[EMAIL PROTECTED] Behalf Of Dianne Ackerman
>>Sent: Thursday, June 02, 2005 11:21 AM
>>To: u2-users@listserver.u2ug.org
>>Subject: Re: [U2] Finding last day of month
>>
>>
>>That method can actually backfire, for example, if your starting date is
>>20040130, you'll end up on Feb 29 instead of Jan 31.  What I would do is
>>replace the day with 01 and add 1 to the month, then iconv and subtract
>>1 day.
>>-Dianne
>>
>>Marco Manyevere wrote:
>>
>>
>>
>>>Hi,
>>>
>>>Given a date like 20040203, I want to return the last valid date for that
>>
>>month and year (20040229 in this case). What is the shortest code fragment
>>to achieve this?
>>
>>
>>>At the moment I'm replacing the day with 01, then iconv, add 35 days to
>
> the
>
>>internal date and then oconv and replace the day again with 01. I'm then
>
> on
>
>>the first day of the next month. I then iconv, subtract 1 day and oconv.
>>
>>
>>>Thanks for any help.
>>
>>---
>>u2-users mailing list
>>u2-users@listserver.u2ug.org
>>To unsubscribe please visit http://listserver.u2ug.org/
>>---
>>u2-users mailing list
>>u2-users@listserver.u2ug.org
>>To unsubscribe please visit http://listserver.u2ug.org/
>>
>>
>
>
> --
> Richard A. Wilson
> Lakeside Systems
> Smithfield, RI, USA
> ---
> u2-users mailing list
> u2-users@listserver.u2ug.org
> To unsubscribe please visit http://listserver.u2ug.org/
> ---
> u2-users mailing list
> u2-users@listserver.u2ug.org
> To unsubscribe please visit http://listserver.u2ug.org/
>
>

--
Richard A. Wilson
Lakeside Systems
Smithfield, RI, USA
Voice 401-231-3959
Fax   206-202-2064
[EMAIL PROTECTED]
www.lakeside-systems.com
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Finding last day of month

2005-06-02 Thread Richard A. Wilson
2100 & 2300 aren't leap years. I guess it depends on the application, antiques, 
historical dates etc.


or future dates like when you will be fully vested in your retirement acct.

 Rich

Allen E. Elwood wrote:


So...it won't be a problem until 2,400?  I can live with that.  And I'm
gettin' up there in my years too.  Just turned 49 last March.


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Richard A.
Wilson
Sent: Thursday, June 02, 2005 12:29 PM
To: u2-users@listserver.u2ug.org
Subject: Re: [U2] Finding last day of month


you cant just use mod(x,4) logic

the following from some website (dont remember where/when I found it)
***
The rule for leap years is that all years divisable by 4 are leap years,
except
those years divisable by 100. The exception is that years divisible by 400
are
leap years

of course only us old foggies that used pick way back when remember this 

Rich

Allen E. Elwood wrote:



I've always used the simple method.

*Initialization section
END.DATES = '31,28,31,30,31,30,31,31,30,31,30,31'
END.DATES = CHANGE(END.DATES,',',@AM)

*Main loop section
LAST.DATE = END.DATES
IF MONTH = 2 AND NOT(MOD(YEAR,4)) THEN LAST.DATE+=1

btw, there may be an error in this, my allergies are truly messing with my
head today.and for the last weekGaaa

Allen

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Dianne Ackerman
Sent: Thursday, June 02, 2005 11:21 AM
To: u2-users@listserver.u2ug.org
Subject: Re: [U2] Finding last day of month


That method can actually backfire, for example, if your starting date is
20040130, you'll end up on Feb 29 instead of Jan 31.  What I would do is
replace the day with 01 and add 1 to the month, then iconv and subtract
1 day.
-Dianne

Marco Manyevere wrote:




Hi,

Given a date like 20040203, I want to return the last valid date for that


month and year (20040229 in this case). What is the shortest code fragment
to achieve this?



At the moment I'm replacing the day with 01, then iconv, add 35 days to


the


internal date and then oconv and replace the day again with 01. I'm then


on


the first day of the next month. I then iconv, subtract 1 day and oconv.



Thanks for any help.


---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/





--
Richard A. Wilson
Lakeside Systems
Smithfield, RI, USA
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/




--
Richard A. Wilson
Lakeside Systems
Smithfield, RI, USA
Voice 401-231-3959
Fax   206-202-2064
[EMAIL PROTECTED]
www.lakeside-systems.com
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread James Canale, Jr.
This is documented back to at least UniData 5.2 and probably earlier than
that though I don't have easy access to the old manuals.  It is in the
"Using UniData" manual in the "Creating Virtual Attributes" section.  You
may wish to search for "Virtual Attribute Functions".  HTH.

Regards,

Jim

 
[snip]
Wow, there is a LAST_DAY function in unidate. I have 6.0 on HPUX and it
works in virtual attributes but not in a basic program. Is that documented
anywhere? What other cool functions are there undocumented?
[snip]
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread colin.alfke
It's in my version 5 documentation - not sure when it was put in. There
is also ADD_MONTHS, LAST_DAY, MONTHS_BETWEEN and NEXT_DAY. See Virtual
Attribute Functions in chapter 5 Creating Virtual Attributes.

Colin Alfke
Calgary, Canada
Where it's Sunny, no pouring rain, no wait it's just cloudy, oops now
it's raining again - OK I give up
 

>-Original Message-
>From: Allen E. Elwood
>
>Wow, when did they sneak that in?  And you forgot the 
>"{current weather condition} in Calgary"  ;-)
>
>Allen in the foggy San Fernando Valley
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Allen E. Elwood
So...it won't be a problem until 2,400?  I can live with that.  And I'm
gettin' up there in my years too.  Just turned 49 last March.


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Richard A.
Wilson
Sent: Thursday, June 02, 2005 12:29 PM
To: u2-users@listserver.u2ug.org
Subject: Re: [U2] Finding last day of month


you cant just use mod(x,4) logic

the following from some website (dont remember where/when I found it)
***
The rule for leap years is that all years divisable by 4 are leap years,
except
those years divisable by 100. The exception is that years divisible by 400
are
leap years

of course only us old foggies that used pick way back when remember this 

Rich

Allen E. Elwood wrote:

> I've always used the simple method.
>
> *Initialization section
> END.DATES = '31,28,31,30,31,30,31,31,30,31,30,31'
> END.DATES = CHANGE(END.DATES,',',@AM)
>
> *Main loop section
> LAST.DATE = END.DATES
> IF MONTH = 2 AND NOT(MOD(YEAR,4)) THEN LAST.DATE+=1
>
> btw, there may be an error in this, my allergies are truly messing with my
> head today.and for the last weekGaaa
>
> Allen
>
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Dianne Ackerman
> Sent: Thursday, June 02, 2005 11:21 AM
> To: u2-users@listserver.u2ug.org
> Subject: Re: [U2] Finding last day of month
>
>
> That method can actually backfire, for example, if your starting date is
> 20040130, you'll end up on Feb 29 instead of Jan 31.  What I would do is
> replace the day with 01 and add 1 to the month, then iconv and subtract
> 1 day.
> -Dianne
>
> Marco Manyevere wrote:
>
>
>>Hi,
>>
>>Given a date like 20040203, I want to return the last valid date for that
>
> month and year (20040229 in this case). What is the shortest code fragment
> to achieve this?
>
>>At the moment I'm replacing the day with 01, then iconv, add 35 days to
the
>
> internal date and then oconv and replace the day again with 01. I'm then
on
> the first day of the next month. I then iconv, subtract 1 day and oconv.
>
>>Thanks for any help.
>
> ---
> u2-users mailing list
> u2-users@listserver.u2ug.org
> To unsubscribe please visit http://listserver.u2ug.org/
> ---
> u2-users mailing list
> u2-users@listserver.u2ug.org
> To unsubscribe please visit http://listserver.u2ug.org/
>
>

--
Richard A. Wilson
Lakeside Systems
Smithfield, RI, USA
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Ed Clark
Wow, there is a LAST_DAY function in unidate. I have 6.0 on HPUX and it
works in virtual attributes but not in a basic program. Is that documented
anywhere? What other cool functions are there undocumented?

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
[EMAIL PROTECTED]
Sent: Thursday, June 02, 2005 2:22 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Finding last day of month


If it's for a UniData dictionary you can use the function LAST_DAY(date)
that will return the last day of the month. I'm not sure if UniVerse has
this function as well.

Eg:
001: I
002: LAST_DAY(INVOICE.DATE)
003: D4
004: Last Day of Month
005: 15R
006: S

Colin Alfke
Calgary, Canada


>-Original Message-
>From: Cliff Bennett
>
>Hi, Marco.  I always ICONV the first day of the next month,
>then subtract a day.  For example:
>
>ANY.DATE = '02-03-2004'
>MO = ANY.DATE[1,2]
>YR = ANY,DATE[7,4]
>MO += 1
>IF MO > 12 THEN
>MO = 1
>YR += 1
>END
>EOM.DATE = ICONV(MO:'-01-':YR, 'D') - 1
>
>This lends itself to a subroutine or function as well.
>
>Regards, Cliff
>
>Marco Manyevere wrote:
>
>> Hi,
>>
>> Given a date like 20040203, I want to return the last valid
>date for that month and year (20040229 in this case). What is
>the shortest code fragment to achieve this?
>>
>> At the moment I'm replacing the day with 01, then iconv, add
>35 days to the internal date and then oconv and replace the
>day again with 01. I'm then on the first day of the next
>month. I then iconv, subtract 1 day and oconv.
>>
>> Thanks for any help.
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Rotella, Leon M.
Here's yet another way...


END.OF.MONTH
0001   EDATES =
"31":@FM:"29":@FM:"31":@FM:"30":@FM:"31":@FM:"30":@FM:"31":@FM:"31":@FM:
"30":@FM:"31
 ":@FM:"30":@FM:"31"
0002   PRINT "INPUT DATE MMDD - ": ; INPUT ODATE
0003   EYEAR = ODATE[1,4]
0004   EMONTH = ODATE[5,2]
0005   EDAY = EDATES
0006   EDATE = EYEAR:EMONTH:EDAY
0007   IDATE = ICONV(EDATE,'D')
0008   IF STATUS() THEN
0009  EDATE -= 1
0010   END
0011   PRINT ODATE,EDATE

Leon.
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Ed Clark
unidata has a LAST_DAY function? what version is that?

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
[EMAIL PROTECTED]
Sent: Thursday, June 02, 2005 2:22 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Finding last day of month


If it's for a UniData dictionary you can use the function LAST_DAY(date)
that will return the last day of the month. I'm not sure if UniVerse has
this function as well.

Eg:
001: I
002: LAST_DAY(INVOICE.DATE)   
003: D4   
004: Last Day of Month
005: 15R  
006: S

Colin Alfke
Calgary, Canada
 

>-Original Message-
>From: Cliff Bennett
>
>Hi, Marco.  I always ICONV the first day of the next month, 
>then subtract a day.  For example:
>
>ANY.DATE = '02-03-2004'
>MO = ANY.DATE[1,2]
>YR = ANY,DATE[7,4]
>MO += 1
>IF MO > 12 THEN
>MO = 1
>YR += 1
>END
>EOM.DATE = ICONV(MO:'-01-':YR, 'D') - 1
>
>This lends itself to a subroutine or function as well.
>
>Regards, Cliff
>
>Marco Manyevere wrote:
>
>> Hi,
>> 
>> Given a date like 20040203, I want to return the last valid 
>date for that month and year (20040229 in this case). What is 
>the shortest code fragment to achieve this?
>> 
>> At the moment I'm replacing the day with 01, then iconv, add 
>35 days to the internal date and then oconv and replace the 
>day again with 01. I'm then on the first day of the next 
>month. I then iconv, subtract 1 day and oconv.
>> 
>> Thanks for any help.
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Allen E. Elwood
Wow, when did they sneak that in?  And you forgot the "{current weather
condition} in Calgary"  ;-)

Allen in the foggy San Fernando Valley

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
[EMAIL PROTECTED]
Sent: Thursday, June 02, 2005 12:22 PM
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Finding last day of month


If it's for a UniData dictionary you can use the function LAST_DAY(date)
that will return the last day of the month. I'm not sure if UniVerse has
this function as well.

Eg:
001: I
002: LAST_DAY(INVOICE.DATE)
003: D4
004: Last Day of Month
005: 15R
006: S

Colin Alfke
Calgary, Canada


>-Original Message-
>From: Cliff Bennett
>
>Hi, Marco.  I always ICONV the first day of the next month,
>then subtract a day.  For example:
>
>ANY.DATE = '02-03-2004'
>MO = ANY.DATE[1,2]
>YR = ANY,DATE[7,4]
>MO += 1
>IF MO > 12 THEN
>MO = 1
>YR += 1
>END
>EOM.DATE = ICONV(MO:'-01-':YR, 'D') - 1
>
>This lends itself to a subroutine or function as well.
>
>Regards, Cliff
>
>Marco Manyevere wrote:
>
>> Hi,
>>
>> Given a date like 20040203, I want to return the last valid
>date for that month and year (20040229 in this case). What is
>the shortest code fragment to achieve this?
>>
>> At the moment I'm replacing the day with 01, then iconv, add
>35 days to the internal date and then oconv and replace the
>day again with 01. I'm then on the first day of the next
>month. I then iconv, subtract 1 day and oconv.
>>
>> Thanks for any help.
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Finding last day of month

2005-06-02 Thread Richard A. Wilson

you cant just use mod(x,4) logic

the following from some website (dont remember where/when I found it)
***
The rule for leap years is that all years divisable by 4 are leap years, except 
those years divisable by 100. The exception is that years divisible by 400 are 
leap years


of course only us old foggies that used pick way back when remember this 

Rich

Allen E. Elwood wrote:


I've always used the simple method.

*Initialization section
END.DATES = '31,28,31,30,31,30,31,31,30,31,30,31'
END.DATES = CHANGE(END.DATES,',',@AM)

*Main loop section
LAST.DATE = END.DATES
IF MONTH = 2 AND NOT(MOD(YEAR,4)) THEN LAST.DATE+=1

btw, there may be an error in this, my allergies are truly messing with my
head today.and for the last weekGaaa

Allen

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Dianne Ackerman
Sent: Thursday, June 02, 2005 11:21 AM
To: u2-users@listserver.u2ug.org
Subject: Re: [U2] Finding last day of month


That method can actually backfire, for example, if your starting date is
20040130, you'll end up on Feb 29 instead of Jan 31.  What I would do is
replace the day with 01 and add 1 to the month, then iconv and subtract
1 day.
-Dianne

Marco Manyevere wrote:



Hi,

Given a date like 20040203, I want to return the last valid date for that


month and year (20040229 in this case). What is the shortest code fragment
to achieve this?


At the moment I'm replacing the day with 01, then iconv, add 35 days to the


internal date and then oconv and replace the day again with 01. I'm then on
the first day of the next month. I then iconv, subtract 1 day and oconv.


Thanks for any help.


---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/




--
Richard A. Wilson
Lakeside Systems
Smithfield, RI, USA
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread colin.alfke
If it's for a UniData dictionary you can use the function LAST_DAY(date)
that will return the last day of the month. I'm not sure if UniVerse has
this function as well.

Eg:
001: I
002: LAST_DAY(INVOICE.DATE)   
003: D4   
004: Last Day of Month
005: 15R  
006: S

Colin Alfke
Calgary, Canada
 

>-Original Message-
>From: Cliff Bennett
>
>Hi, Marco.  I always ICONV the first day of the next month, 
>then subtract a day.  For example:
>
>ANY.DATE = '02-03-2004'
>MO = ANY.DATE[1,2]
>YR = ANY,DATE[7,4]
>MO += 1
>IF MO > 12 THEN
>MO = 1
>YR += 1
>END
>EOM.DATE = ICONV(MO:'-01-':YR, 'D') - 1
>
>This lends itself to a subroutine or function as well.
>
>Regards, Cliff
>
>Marco Manyevere wrote:
>
>> Hi,
>> 
>> Given a date like 20040203, I want to return the last valid 
>date for that month and year (20040229 in this case). What is 
>the shortest code fragment to achieve this?
>> 
>> At the moment I'm replacing the day with 01, then iconv, add 
>35 days to the internal date and then oconv and replace the 
>day again with 01. I'm then on the first day of the next 
>month. I then iconv, subtract 1 day and oconv.
>> 
>> Thanks for any help.
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Finding last day of month

2005-06-02 Thread Don Verhagen
* User Supplied ISO Date
UserDate= '20040203'
UserDateYear= UserDate[1,4] + 0
UserDateMonth   = UserDate[5,2] + 0
UserDateDay = UserDate[7,2] + 0
* First Day Of The Next Month
NextMonthYear   = UserDateYear + (IF (UserDateMonth + 1) > 12 THEN 1 ELSE 0)
NextMonthMonth  = (IF (UserDateMonth + 1) > 12 THEN 1 ELSE (UserDateMonth+1))
NextMonthDay= 1
NextMonthIDate  = ICONV(NextMonthMonth:"/":NextMonthDay:"/":NextMonthYear,"D4/")
*Subtract 1 day from the first day on the next month to get the last day of the 
month supplied
UserDateIEOM = NextMonthIDate -1
UserDateEOM  = 
OCONV(UserDateIEOM,'DY'):OCONV(OCONV(UserDateIEOM,"DM"),"MR(%2)"):OCONV(OCONV(UserDateIEOM,"DD"),"MR(%2)")
*
PRINT 'NextMonthYear  = ':NextMonthYear
PRINT 'NextMonthMonth = ':NextMonthMonth
PRINT 'NextMonthDay   = ':NextMonthDay
PRINT 'EOM Internal   = ':UserDateIEOM
PRINT 'EOM ISO Date   = ':UserDateEOM
*









--
Donald Verhagen  
Application Development Manager
[EMAIL PROTECTED]
Tandem Staffing Solutions, Inc.
1690 S Congress Avenue, Suite 210
Delray Beach, FL 33445  USA
Voice Phone: 561.454.3592 Fax Phone: 561.454.3640 

>>> [EMAIL PROTECTED] 1:31:17 PM 06/02/2005 >>>
Hi,

Given a date like 20040203, I want to return the last valid date for that month 
and year (20040229 in this case). What is the shortest code fragment to achieve 
this?

At the moment I'm replacing the day with 01, then iconv, add 35 days to the 
internal date and then oconv and replace the day again with 01. I'm then on the 
first day of the next month. I then iconv, subtract 1 day and oconv.

Thanks for any help.


-
Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail
---
u2-users mailing list
u2-users@listserver.u2ug.org 
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Norman Morgan
Won't this method choke if ORIG.MM is 12?

===
Norman Morgan <> [EMAIL PROTECTED] <> http://www.brake.com
===
Unscrewing an Oreo lets all the calories out.
===



> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Allen Egerton
> Sent: Thursday, June 02, 2005 12:57 PM
> To: u2-users@listserver.u2ug.org
> Subject: Re: [U2] Finding last day of month
>
>
> From: "Marco Manyevere" <[EMAIL PROTECTED]>
>
>
> > Hi,
> >
> > Given a date like 20040203, I want to return the last valid
> date for that
> month and year (20040229 in this case). What is the shortest code fragment
> to achieve this?
>
> Find the internal date of the first day of the next month, subtract 1, and
> convert it back to external format.
>
> ORIG. = MMDD[1,4]
> ORIG.MM = MMDD[5,2]
> ORIG.DD = MMDD[7,2]
>
> I.LAST.DAY = (ICONV(ORIG.:(ORIG.MM + 1): "01"), "D4/") - 1
> O.LAST.DAY = OCONV(I.LAST.DAY, "D4/"
> ---
> u2-users mailing list
> u2-users@listserver.u2ug.org
> To unsubscribe please visit http://listserver.u2ug.org/
> --
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.322 / Virus Database: 267.4.1 - Release Date: 6/2/2005
>
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.322 / Virus Database: 267.4.1 - Release Date: 6/2/2005
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Paul Sohn
I believe you need to add a month check for December using that method:

IN.DATE='20040203'

NEW. = IN.DATE[1,4]
NEW.MM = (IN.DATE[5,2]+1) 'R%2'
IF NEW.MM=13 THEN
  NEW.MM='01'
  NEW.+=1
END
I.LAST.DAY = ICONV(NEW.MM:"-01-":NEW.),"D4-")-1


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Allen Egerton
Sent: Thursday, June 02, 2005 10:57 AM
To: u2-users@listserver.u2ug.org
Subject: Re: [U2] Finding last day of month

From: "Marco Manyevere" <[EMAIL PROTECTED]>


> Hi,
>
> Given a date like 20040203, I want to return the last valid date for that
month and year (20040229 in this case). What is the shortest code fragment
to achieve this?

Find the internal date of the first day of the next month, subtract 1, and
convert it back to external format.

ORIG. = MMDD[1,4]
ORIG.MM = MMDD[5,2]
ORIG.DD = MMDD[7,2]

I.LAST.DAY = (ICONV(ORIG.:(ORIG.MM + 1): "01"), "D4/") - 1
O.LAST.DAY = OCONV(I.LAST.DAY, "D4/"
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Ian McGowan
Need to take month mod 12, when adding...

D="20040203"
Y=D[1,4]
M=D[5,2]
M+=1
IF M>12 THEN M=1;Y+=1
NEXT.M=ICONV(M:"/01/":Y,"D4/")-1
PRINT OCONV(NEXT.M,"D4Y"):OCONV(NEXT.M,"DM"):OCONV(NEXT.M,"DD")

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> Marco Manyevere
> Sent: Thursday, June 02, 2005 10:31 AM
> To: u2-users@listserver.u2ug.org
> Subject: [U2] Finding last day of month
> 
> 
> Hi,
> 
> Given a date like 20040203, I want to return the last valid 
> date for that month and year (20040229 in this case). What is 
> the shortest code fragment to achieve this?
> 
> At the moment I'm replacing the day with 01, then iconv, add 
> 35 days to the internal date and then oconv and replace the 
> day again with 01. I'm then on the first day of the next 
> month. I then iconv, subtract 1 day and oconv.
> 
> Thanks for any help.
> 
>   
> -
> Yahoo! Messenger NEW - crystal clear PC to PCcalling 
> worldwide with voicemail
> ---
> u2-users mailing list
> u2-users@listserver.u2ug.org
> To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Allen E. Elwood
I've always used the simple method.

*Initialization section
END.DATES = '31,28,31,30,31,30,31,31,30,31,30,31'
END.DATES = CHANGE(END.DATES,',',@AM)

*Main loop section
LAST.DATE = END.DATES
IF MONTH = 2 AND NOT(MOD(YEAR,4)) THEN LAST.DATE+=1

btw, there may be an error in this, my allergies are truly messing with my
head today.and for the last weekGaaa

Allen

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Dianne Ackerman
Sent: Thursday, June 02, 2005 11:21 AM
To: u2-users@listserver.u2ug.org
Subject: Re: [U2] Finding last day of month


That method can actually backfire, for example, if your starting date is
20040130, you'll end up on Feb 29 instead of Jan 31.  What I would do is
replace the day with 01 and add 1 to the month, then iconv and subtract
1 day.
-Dianne

Marco Manyevere wrote:

>Hi,
>
>Given a date like 20040203, I want to return the last valid date for that
month and year (20040229 in this case). What is the shortest code fragment
to achieve this?
>
>At the moment I'm replacing the day with 01, then iconv, add 35 days to the
internal date and then oconv and replace the day again with 01. I'm then on
the first day of the next month. I then iconv, subtract 1 day and oconv.
>
>Thanks for any help.
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Kathleené M Bodine
0001: INPUT DATE
0002: USE.DATE = ICONV(DATE,"D")
0003: MTH = OCONV(USE.DATE,"DM")
0004: YR = OCONV(USE.DATE,"DY4")
0005: IF MTH LT 12 THEN
0006: MTH += 1
0007: END ELSE
0008: MTH = 1
0009: YR += 1
0010: END
0011: NEW.DATE = ICONV(MTH:"/01/":YR,"D") - 1
0012: CRT OCONV(NEW.DATE,"D")


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Marco Manyevere
Sent: Thursday, June 02, 2005 10:31 AM
To: u2-users@listserver.u2ug.org
Subject: [U2] Finding last day of month

Hi,

Given a date like 20040203, I want to return the last valid date for that
month and year (20040229 in this case). What is the shortest code fragment
to achieve this?

At the moment I'm replacing the day with 01, then iconv, add 35 days to the
internal date and then oconv and replace the day again with 01. I'm then on
the first day of the next month. I then iconv, subtract 1 day and oconv.

Thanks for any help.


-
Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with
voicemail
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread gerry-u2ug
same idea with a few less conversions
cdate="20040203"
yr=cdate[1,4]
mn=cdate[5,2]
if mn<12 then mn+=1 else mn=1 ; yr+=1
edate=oconv(iconv(mn'R%2':'-01-':yr,"D")-1,"D")


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Marco Manyevere
Sent: Thursday, June 02, 2005 01:31 PM
To: u2-users@listserver.u2ug.org
Subject: [U2] Finding last day of month


Hi,

Given a date like 20040203, I want to return the last valid date for that month 
and year (20040229 in this case). What is the shortest code fragment to achieve 
this?

At the moment I'm replacing the day with 01, then iconv, add 35 days to the 
internal date and then oconv and replace the day again with 01. I'm then on the 
first day of the next month. I then iconv, subtract 1 day and oconv.

Thanks for any help.


-
Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Perry Taylor
Here's how I do it...

JJ = ICONV(THE.DATE, 'D')
MO = OCONV(JJ, 'DM')
YR= OCONV(JJ, 'DY')
DAY=28
LOOP
  TRY = OCONV(ICONV(MO:'/':DAY+1:'/':YR, 'D'), 'DM')
WHILE TRY = MO DO REPEAT
LAST.DAY = MO:'/':DAY:'/':YR

Perry Taylor

 -Original Message-
From:   Marco Manyevere [mailto:[EMAIL PROTECTED]
Sent:   Thu Jun 02 14:05:42 2005
To: u2-users@listserver.u2ug.org
Subject:[U2] Finding last day of month

Hi,

Given a date like 20040203, I want to return the last valid date for that
month and year (20040229 in this case). What is the shortest code fragment to
achieve this?

At the moment I'm replacing the day with 01, then iconv, add 35 days to the
internal date and then oconv and replace the day again with 01. I'm then on
the first day of the next month. I then iconv, subtract 1 day and oconv.

Thanks for any help.


-
Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for
the sole use of the intended recipient(s) and may contain confidential and
privileged information.  Any unauthorized review, use, disclosure or
distribution is prohibited. ZirMed, Inc. has strict policies regarding the
content of e-mail communications, specifically Protected Health Information,
any communications containing such material will be returned to the
originating party with such advisement noted. If you are not the intended
recipient, please contact the sender by reply e-mail and destroy all copies of
the original message.
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Finding last day of month

2005-06-02 Thread Dianne Ackerman
That method can actually backfire, for example, if your starting date is 
20040130, you'll end up on Feb 29 instead of Jan 31.  What I would do is 
replace the day with 01 and add 1 to the month, then iconv and subtract 
1 day.

-Dianne

Marco Manyevere wrote:


Hi,

Given a date like 20040203, I want to return the last valid date for that month 
and year (20040229 in this case). What is the shortest code fragment to achieve 
this?

At the moment I'm replacing the day with 01, then iconv, add 35 days to the 
internal date and then oconv and replace the day again with 01. I'm then on the 
first day of the next month. I then iconv, subtract 1 day and oconv.

Thanks for any help.

---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Finding last day of month

2005-06-02 Thread Cliff Bennett
Hi, Marco.  I always ICONV the first day of the next month, then 
subtract a day.  For example:


ANY.DATE = '02-03-2004'
MO = ANY.DATE[1,2]
YR = ANY,DATE[7,4]
MO += 1
IF MO > 12 THEN
   MO = 1
   YR += 1
END
EOM.DATE = ICONV(MO:'-01-':YR, 'D') - 1

This lends itself to a subroutine or function as well.

Regards, Cliff

Marco Manyevere wrote:


Hi,

Given a date like 20040203, I want to return the last valid date for that month 
and year (20040229 in this case). What is the shortest code fragment to achieve 
this?

At the moment I'm replacing the day with 01, then iconv, add 35 days to the 
internal date and then oconv and replace the day again with 01. I'm then on the 
first day of the next month. I then iconv, subtract 1 day and oconv.

Thanks for any help.


-
Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Finding last day of month

2005-06-02 Thread Timothy Snyder
Marco Manyevere <[EMAIL PROTECTED]> wrote on 06/02/2005 01:31:17 PM:

> Given a date like 20040203, I want to return the last valid date for
> that month and year (20040229 in this case). What is the shortest 
> code fragment to achieve this?


Ooh!  A good old-fashioned programming challenge.  I think the following 
is simpler and, because it uses half as many date conversions, will burn 
fewer CPU cycles than your method.

INPUT ORIG.DATE
YEAR = ORIG.DATE[1,4]
MONTH = ORIG.DATE[5,2]
MONTH += 1
IF MONTH EQ 13 THEN MONTH = 1; YEAR += 1
NEW.DATE.I = ICONV(MONTH:'/01/':YEAR, 'D') - 1
NEW.DATE =  CHANGE(OCONV(NEW.DATE.I, 'DYMD'), ' ', '')
CRT NEW.DATE

This may need to be modified if your default date convention is not 
MM/DD/YY.  It also assumes that the input date is in the correct format.

Tim Snyder
Consulting I/T Specialist , U2 Professional Services
North American Lab Services
DB2 Information Management, IBM Software Group
[EMAIL PROTECTED]
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Finding last day of month

2005-06-02 Thread Bob Woodward
I might offer a small modification to your code snippet as noted below.

BobW
> 
> From: "Marco Manyevere" <[EMAIL PROTECTED]>
> 
> 
> > Hi,
> >
> > Given a date like 20040203, I want to return the last valid date for
> that
> month and year (20040229 in this case). What is the shortest code
fragment
> to achieve this?
> 
> Find the internal date of the first day of the next month, subtract 1,
and
> convert it back to external format.
> 
> ORIG. = MMDD[1,4]
> ORIG.MM = MMDD[5,2]
> ORIG.DD = MMDD[7,2]
> 
* IN CASE IT'S DECEMBER
IF ORIG.MM = 12 THEN
   ORIG. += 1
   ORIG.MM = 0
END
> I.LAST.DAY = (ICONV(ORIG.:(ORIG.MM + 1): "01"), "D4/") - 1
> O.LAST.DAY = OCONV(I.LAST.DAY, "D4/")
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Finding last day of month

2005-06-02 Thread Lembit Pirn
You can try ICONV(date,code) and check STATUS(). If status() returns 
other than 0 then date is valid


Marco Manyevere wrote:


Hi,

Given a date like 20040203, I want to return the last valid date for that month 
and year (20040229 in this case). What is the shortest code fragment to achieve 
this?

At the moment I'm replacing the day with 01, then iconv, add 35 days to the 
internal date and then oconv and replace the day again with 01. I'm then on the 
first day of the next month. I then iconv, subtract 1 day and oconv.

Thanks for any help.


-
Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

 



--
Lembit Pirn
7+7 Software
Tondi 1
Tallinn 11313

tel. +372 6566232
[EMAIL PROTECTED]
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


Re: [U2] Finding last day of month

2005-06-02 Thread Allen Egerton
From: "Marco Manyevere" <[EMAIL PROTECTED]>


> Hi,
>
> Given a date like 20040203, I want to return the last valid date for that
month and year (20040229 in this case). What is the shortest code fragment
to achieve this?

Find the internal date of the first day of the next month, subtract 1, and
convert it back to external format.

ORIG. = MMDD[1,4]
ORIG.MM = MMDD[5,2]
ORIG.DD = MMDD[7,2]

I.LAST.DAY = (ICONV(ORIG.:(ORIG.MM + 1): "01"), "D4/") - 1
O.LAST.DAY = OCONV(I.LAST.DAY, "D4/"
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


[U2] Finding last day of month

2005-06-02 Thread Marco Manyevere
Hi,

Given a date like 20040203, I want to return the last valid date for that month 
and year (20040229 in this case). What is the shortest code fragment to achieve 
this?

At the moment I'm replacing the day with 01, then iconv, add 35 days to the 
internal date and then oconv and replace the day again with 01. I'm then on the 
first day of the next month. I then iconv, subtract 1 day and oconv.

Thanks for any help.


-
Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/