Clovertech
› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › Date Formatting Problem
In an Xlate, I want to convert a date where the day and month have no leading zero. As an example, today is presented as 3/10/2008.
I would like to know the best way to convert this to the format CCYYMMDD.
Thanks,
Dave
set dt 3/10/2008
set newdt [clock format [clock scan $dt] -format %Y%m%d]
=> 20080310
That simple! Many thanks.
If I had date that also included the time, how would I use clock to just return the date? For example my date/time value is: 20080921194800 and I want to return only 09/21/2008.
read up on “clock scan” in tclhelp. It accepts several formats.
In this case you would only want to send teh first 8 digits of your timestamp to clock scan in the code above:
set dt [string range $datetime 0 7]
Rob Abbott Cloverleaf Emeritus
Thanks Rob.