Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 4650
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: 10326
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 How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts question about dfsms management clas... Hervey Martinez IBM Tools 0 Tue Oct 10, 2017 6:19 pm
This topic is locked: you cannot edit posts or make replies. Rexx to execute spool commands upendrasri CLIST & REXX 5 Wed Oct 04, 2017 6:54 am
This topic is locked: you cannot edit posts or make replies. Rexx to execute spool commands upendrasri CLIST & REXX 47 Fri Sep 29, 2017 1:08 pm
No new posts ejck thru rexx to multiple jobs insid... Susanta All Other Mainframe Topics 5 Tue Sep 19, 2017 1:39 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us