On 6/29/16 9:28 AM, Michael wrote:
> echo![str("!hpyyyymmdd",5,2)]/![str("!hpyyyymmdd",7,2)]/![str("!hpyyyymmdd",3,2)]
Please note that the HPYYYYMMDD variable is already a string variable:
Frodo: calc typeof(HPYYYYMMDD)
2, $2, %2
So you don't have to dereference it with ! inside double quotes. In
other words, the following works just as well, is easier to read, and
might even execute a bit faster:
Frodo: echo
![str(hpyyyymmdd,5,2)]/![str(hpyyyymmdd,7,2)]/![str(hpyyyymmdd,3,2)]
06/29/16
Also note that since you're asking for the value of HPYYYYMMDD three
different times, there's the tiniest chance that if you executed this
right at last part of the second at 23:59:59, then the value could roll
over to a new date in the 2nd or 3rd call, and you could possibly get
the wrong date, or even year. Unlikely, I know. But to avoid that, you'd
want to capture the current date once, then operate on that, as in:
Frodo: setvar my_date hpyyyymmdd
Frodo: echo ![str(my_date,5,2)]/![str(my_date,7,2)]/![str(my_date,3,2)]
06/29/16
Cheers,
Barry
-------- Original Message --------
Subject: Re: Date format question
Date: Wed, 29 Jun 2016 11:28:29 -0500
From: Michael <[log in to unmask]>
Reply-To: Michael <[log in to unmask]>
To: [log in to unmask]
Not sure if this is the easiest, but it works for me:
First echo:
echo
![str("!hpyyyymmdd",5,2)]/![str("!hpyyyymmdd",7,2)]/![str("!hpyyyymmdd",3,2)]
Then setvar:
setvar mydate
'![str("!hpyyyymmdd",5,2)]/![str("!hpyyyymmdd",7,2)]/![str("!hpyyyymmdd",3,2)]'
Note in the setvar command, the usage of single-quote and double-quote.
--
Michael Anderson.
On 06/29/2016 11:01 AM, Reggie Monroe wrote:
> What would be the easiest way to get a variable date in the following below format on a HP3000 OS version 7.0 and 7.5?
>
> 06/29/16
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|