Get Rexx date a wekk from today in European



IBM's Command List programming language & Restructured Extended Executor

Get Rexx date a wekk from today in European

Postby deucalion0 » Fri Oct 31, 2014 7:01 pm

Hello, I have spent all day trying to get the date 7 days from today in European format.

I cannot see a way to do this in the manuals, so I am trying to write some code to get it myself.

Here is what I have written so far, but it is not right, not at all:

/* rexx*/                                                               
EUdate  = Date(european) /*todays date in eu format */                 
bdate = Date(base) /*base date, numerical format */                     
say 'base date is 'bdate /* display base date */                       
num = bdate+7 /* store value of base date plus 7 days */               
say 'num is ' num /* display base date + 7 days */                     
days = bdate + Date('european','num', 'Standard') /* calculate date */ 
say 'todays date is 'EUdate /*show todays date */                       
say 'a week from this date will be 'days /* show date week from today */
exit                                                                   


The sources I used to write this code are:

http://www.oorexx.org/docs/rexxref/x23579.htm

and

http://nokix.sourceforge.net/help/learn_rexx/variable.htm


I think my issue on line 7 in my code, is that I am trying to use a variable (num) instead of a number such as 772345, and the function does not detect it is a variable. I was trying to concatenate my variable as a parameter to the date function but it did not work.

These are some of the things I tried:

days = bdate + Date('european','.num.', 'Standard') /* calculate date */

days = bdate + Date('european',num, 'Standard') /* calculate date */

days = bdate + Date('european',.num., 'Standard') /* calculate date */


Any assistance would be great. What I want to achieve is just displaying today's date and the date a week from today. Rexx is great but sometimes simple things seem difficult to do.

Thank you!
deucalion0
 
Posts: 58
Joined: Thu Jul 31, 2014 3:47 pm
Has thanked: 32 times
Been thanked: 0 time

Re: Get Rexx date a wekk from today in European

Postby enrico-sorichetti » Fri Oct 31, 2014 8:28 pm

looks like You did not read carefully the manuals
the sources You read NEVER hinted to do it the way You posted

/* rexx*/
bdate  = Date("B") /* today base format */
say "bdate" bdate

edate  = Date("E") /* today european format */
say "edate" edate

nextb  = bdate +7 /* today + 7 base format */
say "nextb" nextb

nextd  = Date("E", bdate, "B") /* today + 7 european format */
say "nextd" nextd
exit



bdate 735536
edate 31/10/14
nextb 735543
nextd 31/10/14


furthermore You have some kind misunderstanding of REXX syntax ...

... You use string constants where variable are needed
... You confused the formats of the dates

num is not in Standard format ... but in Base format
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3002
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: Get Rexx date a wekk from today in European

Postby deucalion0 » Mon Nov 03, 2014 3:31 am

Thank you very much Enrico, I do not understand Rexx fully yet, thank you for showing me were my mistakes were, now I can learn from this.

In your code though, it shows that the European format is the same date, not a week later, is this a mistake or intentional?

I appreciate your help!

Thank you!
deucalion0
 
Posts: 58
Joined: Thu Jul 31, 2014 3:47 pm
Has thanked: 32 times
Been thanked: 0 time

Re: Get Rexx date a wekk from today in European

Postby enrico-sorichetti » Mon Nov 03, 2014 4:54 am

just a cut and paste glitch ...

instead of ...
nextd  = Date("E", bdate, "B") /* today + 7 european format */


it should have been
nextd  = Date("E", nextb, "B") /* today + 7 european format */


but ... IMHO it should have been easy for You also to spot the typo
after all i tried to use a consistent variable naming convention

bdate,edate for the current date

nextb,nextd for curent + 7
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3002
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post