Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to change date variable "year" to yy only

Status
Not open for further replies.

zeroendless

Programmer
Mar 20, 2003
23
US
I tried the method and sample from here and procomm plus help files, but can't seem to find a way to change the variable &Date and &Ltime year from yyyy to yy only

For instance,
strfmt datestring "%02d%02d%02d" iMonth iDay iYear
I changed the format to %02d or %d doesn't seem to affect the year format, it' still showing 04282003

i need a variable as in date format yy/mm/dd. simple as that, i am new to aspect. so, help me out here, aspect guru.
 
Here is a script to do so. I broke up $DATE with multiple strtok commands since it already has the year in two-digit format instead of four-digit.

proc main
string sDay, sMonth, sYear, sDate
integer iDay, iMonth

sDate = $DATE
strtok sMonth sDate "/"
strtok sDay sDate "/"
strtok sYear sDate "/"
atoi sMonth iMonth
atoi sDay iDay
strfmt sDate "%s%02d%02d" sYear iMonth iDay
endproc

aspect@aspectscripting.com
 
it's just me? I'm still getting the year as yyyy when tested using usermsg. I'm using windows xp
 
$DATE uses whatever the "short date" format in Control Panel (under Regional Settings) is configured as. My NT machine was set to MM/DD/YY, but it looks like the format is MM/DD/YYYY on XP. You can use the code above and add the line:

strdelete sDate 0 2

to delete the first two character (20 in this case) from the string. You should also be able to use this with your original code if you still have that in your script.


aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top