IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Question in dates using rexx


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
nkothako

Active User


Joined: 26 Nov 2008
Posts: 125
Location: chennai

PostPosted: Wed Nov 26, 2008 7:06 pm
Reply with quote

How to get previous date of current date
How to get next date of current date
How to get month first date of current date
How to get last month of current date

Always my input will be yyyymmdd format, need output format should be YYYYDDD using rexx
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Wed Nov 26, 2008 7:30 pm
Reply with quote

Have you looked up the usage of the Date Function?

Anyway, the first two are easy:
Code:

/* REXX */
thedate = ... /* Date in YYYYMMDD format */
basedate = Date(B,thedate,S)
prevdate = Date(S,basedate-1,B)
prevyyyy = Left(prevdate,4)
nextdate = Date(S,basedate+1,B)
nextyyyy = Left(nextdate,4)

Say 'Current Date:'thedate
Say 'Previous Date:'||prevyyyy||Right(Date(D,prevdate,S),3,'0')
Say 'Next Date:'||nextyyyy||Right(Date(D,nextdate,S),3,'0')


I'm not clear what you mean by the next two:

How to get month first date of current date
How to get last month of current date
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Nov 26, 2008 8:13 pm
Reply with quote

Code:

#! /opt/ooRexx/bin/rexx
/*REXX - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/*                                                                    */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
Trace "O"

say "***********      " "previous day"
say "day   date(-1)-s " date("S",date("b")-1,"b")
say "day   date(-1)-j " left(date("s",date("b")-1,"b"),4) || right(date("d",date("b")-1,"b"),3,"0")

say "***********      " "current  day"
say "day   date()-s   " date("S")
say "day   date()-j   " left(date("S"),4) || right(date("d"),3,"0")

say "***********      " "next     day"
say "day   date(+1)-s " date("S",date("b")+1,"b")
say "day   date(+1)-j " left(date("s",date("b")+1,"b"),4) || right(date("d",date("b")+1,"b"),3,"0")

parse value date("s") with 1 y 5 m 7 .

fdcm = y || m || "01"

py  = y
pm   = m - 1
if   pm = 0 then do
   pm = 12
   py = py - 1
end
fdpm = py || pm || "01"

ny  = y
nm   = m + 1
if   nm = 13 then do 
   nm = "01"
   ny = ny + 1
end
fdnm = ny || nm || "01"

wy  = ny
wm   = nm + 1
if   wm = 13 then do 
   wm = "01"
   wy = wy + 1
end
fdwm = wy || wm || "01"


say "***********      " "previous month"
say "first         -s " fdpm
say "first         -j " left(fdpm,4) || right(date("d",fdpm,"s"),3,"0")
say "last          -s " date("S",date("b",fdcm,"s")-1,"b")
say "day           -j " left(date("S",date("b",fdcm,"s")-1,"b"),4) || right(date("d",date("b",fdcm,"s")-1,"b"),3,"0")


say "***********      " "current month"
say "first         -s " fdcm
say "first         -j " left(fdcm,4) || right(date("d",fdcm,"s"),3,"0")
say "last          -s " date("S",date("b",fdnm,"s")-1,"b")
say "day           -j " left(date("S",date("b",fdnm,"s")-1,"b"),4) || right(date("d",date("b",fdnm,"s")-1,"b"),3,"0")

say "***********      " "next    month"
say "first         -s " fdnm
say "first         -j " left(fdnm,4) || right(date("d",fdnm,"s"),3,"0")
say "last          -s " date("S",date("b",fdwm,"s")-1,"b")
say "day           -j " left(date("S",date("b",fdwm,"s")-1,"b"),4) || right(date("d",date("b",fdwm,"s")-1,"b"),3,"0")
exit

Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top