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: 4648
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: 10231
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 cdoe to purge a JOB from spool a... Sulabh Agrawal CLIST & REXX 11 Thu Mar 09, 2017 11:36 am
No new posts Asynchronous CICS Processing Question moezbud CICS 0 Mon Mar 06, 2017 6:13 pm
No new posts CICS Question RE: Browse, Readnext an... moezbud CICS 7 Sun Mar 05, 2017 5:45 am
No new posts Overriding PS data in rexx Shaheen Shaik CLIST & REXX 8 Fri Mar 03, 2017 5:08 pm
No new posts REXX compiled via RXTCOMP sergeyken CLIST & REXX 7 Tue Feb 07, 2017 9:41 pm


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