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
Need to Convert OBX:5 value YYYYMMDDHHMMSS into MM/DD/YYYY HH:MM
Steve Simmons
Need to convert the Convert OBX:5 value YYYYMMDDHHMMSS into MM/DD/YYYY HH:MM.
Trying to use Xlate with the TCL.
Not having very much luck.
Thanks.
Find more posts tagged with
Clovertech
Comments
Paul Bishop
There are multiple ways to do it. Off the top of my head, if you know that the input will ALWAYS be in that format (YYYYMMDDHHMMSS), then you can use the clock command (copy pre-proc):
<pre>lassign $xlateInVals in_obx_5
set out_obx_5 [clock format [clock scan $in_obx_5 -format "%Y%m%d%H%M%S"] -format "%m/%d/%Y %H:%M"]
set xlateOutVals [list $out_obx_5]</pre>
The problem with using the clock command is that if it doesn't match the input format on the scan portion, it will fail.
Another way of doing it is to use string range commands to pull out each element of the date and time, and then set the output variable to what you need it to be.
There is also the format command, but I always have to look up all the options for it. Those are the first ones I thought of off the top of my head, but I'm sure there are many other ways as well.
I would put coding before it to verify it matches the input format you are expecting (length, all numeric, etc).
Hope this helps!
david_barr
Probably a regsub is the easiest way to do this. Something like:
[pre]
set xlateOutVals [list [regsub {(....)(..)(..)(..)(..)(..)} [lindex xlateInVals 0] {\2/\3/\1 \4:\5}]]
[/pre]
Keith McLeod
Try this:
regsub -- {(\d{8})(\d{4,6})} [lindex $xlateInVals 0] {\1 \2} dt
set xlateOutVals [list [clock format [clock scan $dt] -format "%m/%d/%Y %H:%M:%S"]]
Example:
hcitcl>set xlateInVals 20240402120000
20240402120000
hcitcl>regsub -- {(\d{8})(\d{4,6})} [lindex $xlateInVals 0] {\1 \2} dt
1
hcitcl>echo $dt
20240402 120000
set xlateOutVals [list [clock format [clock scan $dt] -format "%m/%d/%Y %H:%M:%S"]]
{04/02/2024 12:00:00}
Hope this helps...
Steve Simmons
Thanks Paul, that worked great.
Yes, the input will always be the same.
Keith McLeod
hcitcl>set xlateInVals 20240402120000
20240402120000
hcitcl>regsub -- {(\d{8})(\d{4,6})} [lindex $xlateInVals 0] {\1 \2} dt
1
hcitcl>echo $dt
20240402 120000
hcitcl>set xlateOutVals [list [clock format [clock scan $dt] -format "%m/%d/%Y %H:%M:%S"]]
{04/02/2024 12:00:00}
Jim Kosloskey
And... if you are on release 6.0 or later of Cloverleaf, and you do not want to use Tcl:
Use the STRING Action functions to break out the Source unformatted Date/Time:
STRING XlateStrSubString 0 3 -->
@CCYY
STRING XlateStrSubString 4 5 -->
@MM
STRING XlateStrSubString 6 7 -->
@DD
STRING XlateStrSubString 8 9 -->
@HH
STRING XlateStrSubString 10 11 -->
@MIN
Then CONCAT together with separators:
@MM
---> Destination
=/
@DD
=/
@CCYY
=
@HH
=:
@MIN
Jim Vilbrandt
Here's one more:
<pre>set inStr [lindex $xlateInVals 0]
if [clength $inStr] {
set obStr [fmtclock [clock scan $inStr -format %Y%m%d%H%M%S] "%m/%d/%Y %H:%M:%S"]
xpmstore $xlateId [lindex $xlateOutList 0] c $obStr
}</pre>