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
Cloverleaf
Date format
Collin Praster
Hello I am looking for some assistance on a date format
I have a date coming in on 1(0).0(0).PID(0).#7(0).[0]
its coming in as 19990101
I need to change it to month day year and add /
so 01/01/1999
Thank you
Find more posts tagged with
Clovertech
Comments
Boris Perov
set myDate [lindex $xlateInVals 0]
set xlateOutVals [clock format $myDate -format "%m/%d/%Y"]
Jim Kosloskey
If in an Xlate and no Tcl:
Use the STRING Action substring function to extract the ccyy, mm, and dd elements to temp variables.
Then use a CONCAT Action to combine the respective temp variables using / as the separator.
If you are going to use Tcl don't forget the xlateOut lists (vals, etc) are LISTS and should be treated as such.
Tipu Razaq (Clovertech)
If you want a one-liner and a more thorough attempt, it will be like so:
lset xlateOutVals 0 [clock format [clock scan [lindex $xlateInVals 0] -format "%Y%d%m"] -format "%m/%d/%Y"]
You really should tell TCL how the incoming date is formatted, otherwise it'll take a best guess which may result in incorrect output data and/or just error entirely.
Paul Bishop
you can do this with a code snippet in the translate. couple of different ways - first is to string range each portion out, then rebuild it with the slashes. Second way is to use clock scan/clock format.
clock scan example
lassign $xlateInVals in_pid_7_0
set out_pid_7_0 [clock format [clock scan $in_val -format %Y%m%d] -format %m/%d/%Y]
set xlateOutVals [list $out_pid_7_0]
string range example
lassign $xlateInVals in_pid_7_0
set out_pid_7_0 "[string range $in_pid_7_0 4 5]/[string range $in_pid_7_0 6 7]/[string range $in_pid_7_0 0 3]"
set xlateOutVals [list $out_pid_7_0]
formatting is weird - removed my "list $out_pid_7_0" within brackets after the "set XlateOutVals"
Boris Perov
Ha! forgot to copy and paste the clock scan command... Looks like Tipu gave you the more "complete" answer. Thanks ;-)
Collin Praster
Hello I tired your solution and received this error
MESSAGE 1
Tcl callout error
lset xlateOutVals 0 [clock format [clock scan [lindex $xlateInVals 0] -format “%Y%d%m”] -format “%m/%d/%Y”]:
errorCode: NONE
errorInfo:
bad switch "-format": must be -base or -gmt
while executing
"clock scan [lindex $xlateInVals 0] -format “%Y%d%m”"
invoked from within
"clock format [clock scan [lindex $xlateInVals 0] -format “%Y%d%m”] -format “%m/%d/%Y”"
invoked from within
"lset xlateOutVals 0 [clock format [clock scan [lindex $xlateInVals 0] -format “%Y%d%m”] -format “%m/%d/%Y”]"
<End of errorInfo>
Collin Praster
Hello I tried Tipu's solution but I received the below error
MESSAGE 1
Tcl callout error
lset xlateOutVals 0 [clock format [clock scan [lindex $xlateInVals 0] -format “%Y%d%m”] -format “%m/%d/%Y”]:
errorCode: NONE
errorInfo:
bad switch “-format”: must be -base or -gmt
while executing
“clock scan [lindex $xlateInVals 0] -format “%Y%d%m””
invoked from within
“clock format [clock scan [lindex $xlateInVals 0] -format “%Y%d%m”] -format “%m/%d/%Y””
invoked from within
“lset xlateOutVals 0 [clock format [clock scan [lindex $xlateInVals 0] -format “%Y%d%m”] -format “%m/%d/%Y”]”
<End of errorInfo>
Tipu Razaq (Clovertech)
Interesting. Works when I try it.
Which version of TCL are you using? 'info patchlevel' command should tell you.
I think the format option was added in 8.5
I also noticed a mix up in the original code snippet. I'm assuming the date is coming in the following format: YYYYMMDD and you want it turned into MM/DD/YYYY
Updated snippet below:
lset xlateOutVals 0 [clock format [clock scan [lindex $xlateInVals 0] -format %Y%m%d] -format %m/%d/%Y]
Collin Praster
I am still using cloverleaf 5.8
Collin Praster
I am still using cloverleaf 5.8 so not sure what version that is using
Charlie Bursell
Why jump through the hoops of tearing the string apart and then put it back together? The clock command was designed for cases like this. Boris was on the right track but his command was incomplete.
Try
set myDate [lindex $xlateInVals 0]
set xlateOutVals [list [clock format [clock scan $myDate] -format "%m/%d/%Y"]]