Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Question in dates using rexx

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: Question in dates using rexx
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

Moderator Team Head


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

PostPosted: Wed Nov 26, 2008 7:30 pm    Post subject: Reply to: Question in dates using rexx
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10274
Location: italy

PostPosted: Wed Nov 26, 2008 8:13 pm    Post subject: Reply to: Question in dates using rexx
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts REXX to get the all datasets name parasmalik20 CLIST & REXX 5 Tue Jul 18, 2017 9:10 pm
No new posts How system know which REXX to excute? jackzhang75 CLIST & REXX 14 Thu Jul 06, 2017 1:09 am
No new posts REXX - Dynamic file Creation d_sarlie CLIST & REXX 7 Tue Jun 27, 2017 7:30 pm
No new posts REXX WTO for console message bipinpeter CLIST & REXX 6 Tue Jun 27, 2017 3:56 pm
No new posts Convert CLIST to REXX cvnlynn CLIST & REXX 12 Tue Jun 27, 2017 2:06 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us