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!

need leading zero when date is a single digit date

Status
Not open for further replies.

112055

Programmer
May 13, 2002
61
US
I have checked my system date on my computer. It is set properly with the shortdate format: MM/dd/YYYY. I use the $Date but make adjustment to set it specifically for a report from 1st of the Month to today minus one day.
Example: 05/1/2002 to 05/7/2002

I would like to keep it 05/01/2002 to 05/07/2002 instead.

My curiosity is, does the changes on the dates messed up the leading zero for single digit date? If so, how would I go about correcting it?

many thanks!
 
Here's a script that I posted a while back that uses the ltimeints command to break day, month, year, etc. into separate variables, then uses the strfmt command to create a YYYYMMDD string. I imagine that the %02d format variable in the strfmt command is what you need to fix your problem. Here's the script, hopefully it will be enough to get you going, but give a shout if you have any questions.

proc main
integer iDay, iMonth, iYear, iHour, iMin, iSec
string sCapture

ltimeints $LTIME iYear iMonth iDay iHour iMin iSec

strfmt sCapture "%d%02d%02d" iYear iMonth iDay
endproc
 
Hello,

See if this Helps. You may have to play with it a Little Bit if you need to subtract a 1 from the Day or Month. Use the NUMTOSTR or STRTONUM Functions for that.

proc FileDateSetup
string szMonth, szDay, szYear
strextract szMonth $DATE "/" 0
strextract szDay $DATE "/" 1
strextract szYear $DATE "/" 2
strfmt szMonth "%02.2s" szMonth
strfmt szDay "%02.2s" szDay
strfmt szDate "%s/%s/%s.txt" szDay szMonth szYear
endproc

String szDate will be your Formated Date String

Write back if you need more assistance.

Hank
 
Hi Hank, Hi knob...you guys are great...it shows up nicely....(o:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top