infor.com
concierge
infor u
developer portal
documentation central
customer center
Posts
Categories
Groups
ERPs
CSD
FSM/HRT
LN
M3
Syteline/ CSI
Hubs
Developer
Healthcare
Hospitality
Public Sector
Onboarding
Release Center
CloudSuites
Aerospace & Defense (LN)
Automotive (LN)
Chemicals (M3)
Corporate (FSM/HRT)
Distribution (Sx.e/CSD)
Distribution Enterprise (M3)
Engineering & Construction (LN)
Fashion (M3)
Food & Beverage (M3)
Healthcare (FSM/HRT)
Industrial (Syteline/CSI)
Industrial Enterprise (LN)
Manufacturing (M3)
Public Sector (FSM/HRT)
Solutions
Supply Chain Management (SCM)
Human Capital Management (HCM)
Events
Groups
User Groups
Your Groups
About
Email Community Support
Infor News
Migrated Forums
Home
Clovertech
Clovertech Archive
Read Only Archives
Cloverleaf
Cloverleaf
convert datetime from YYYYmmddhhmm to dd/mm/yyyy hh:mm
Hongle Sun
I use a tcl script and try to convert to with following statment
#Collecteddate has value of 200801180954
set Collecteddate_NEW [clock format [clock scan $Collecteddate -format "%Y/%m/%d %H:%M"]
But it returms me an error message says " unable to convert date-time string "200801180954"
any ideal ? Thanks for the help
Find more posts tagged with
Clovertech
Comments
Charlie Bursell
The scan expects a list of date and time or date alone.
do this before you scan it
regsub -- {(d{8})(d+)} $Collecteddate {1 2} Collecteddate
Now it will scan
John Mercogliano
There is one problem with that way at least with QDX 5.2's version of tcl. If the original value is 200801180001 then the input would be
20080118 0001
But the output from clock gives you
Fri Jan 18 01:00:00 EST 2008
instead of
Fri Jan 18 00:01:00 EST 2008
This is a known bug in tcl that is not fixed until 8.5. This affects all times between 0001 and 0059 as without the the colon it treats the value as an integer.
It is safest to convert the time portion to HH:MM
http://sourceforge.net/tracker/index.php?func=detail&aid=1090413&group_id=10894&atid=110894
You can use this regsub command:
regsub -- {(d{8})(d{2})(d{2})} $Collecteddate {1 2:3} Collecteddate
and of course
regsub -- {(d{8})(d{2})(d{2})(d{2})} $Collecteddate {1 2:3:4} Collecteddate
if you have seconds. I used an if statement to choose which one.
Now that we are on the subject, does anyone know of a way to do this with and without seconds in one regsub command