Page 1 of 1

Get Rexx date a wekk from today in European

PostPosted: Fri Oct 31, 2014 7:01 pm
by deucalion0
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!

Re: Get Rexx date a wekk from today in European

PostPosted: Fri Oct 31, 2014 8:28 pm
by enrico-sorichetti
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

Re: Get Rexx date a wekk from today in European

PostPosted: Mon Nov 03, 2014 3:31 am
by deucalion0
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!

Re: Get Rexx date a wekk from today in European

PostPosted: Mon Nov 03, 2014 4:54 am
by enrico-sorichetti
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