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
___