› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › Reformat dates
I have an inbound field with ‘19780411’. I need to write it out as
’04/11/1978′.
Version 5.7 on AIX.
Thanks.
Mike C.
Mike,
The clock command:
clock format -format %m/%d/%Y
where is the date to be reformatted should do the trick.
email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 61 years IT – old fart.
Mike,
I missed one command.
Here is the correct command:
clock format [clock scan ] -format %m/%d/%Y
where is the date to be reformatted should do the trick.
The clock scan which I omitted in the previous post converts the human redable date to an internal format that the clock format needs.
email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 61 years IT – old fart.
My problem is I have to reformat from the ccyymmdd that is coming in
to be mm/dd/ccyy.
I’m not having any luck with doing that.
set input $xlateInVals
set date [string range $input 0 7]
regsub {(d{4})(d{2})(d{2})} $date {2-3-1} newdate;
set xlateOutVals $newdate
I’m just tying to get the data switched around and can’t seem to get that to work. Seems the outval is the same as the inval…
Change:
set input $xlateInVals
To:
set input [lindex $xlateInVals 0]
And
Change:
set xlateOutVals $newdate
To:
set xlateOutVals
I know I’m missing something really stoopid…
The input date is: 19870411
instream proc:
set input [lindex $xlateInVals 0]
set indate [string range $input 0 7]
regsub {(d{4})(d{2})(d{2})} $indate {2-3-1} newdate;
set xlateOutVals
OutVals still is 19780411.
Trying to get to 04111978 initially, then 04/11/1978 finally. Figured I’d try to at least reformat the date then work on the ‘/’
Your code works for me:
hcitcl>set datelist
hcitcl>set input [lindex $datelist 0]
19870411
hcitcl>set indate [string range $input 0 7]
19870411
hcitcl>regsub {(d{4})(d{2})(d{2})} $indate {2-3-1} newdate
1
hcitcl>set xlateOutVals
04-11-1987
hcitcl>
Try adding echo statements:
echo >$xlateInVals<
Okay…that is really odd.
The echo from the xlate does show:
19870411
04-11-1987
and yet the value written out is the original. Thanks Mike for the echo idea. Now…just to figure out the rest!
I’ll post what the outcome is…
Mike,
Take a look at the field definition of the outbound field that you are mapping to. Is it a date field(?), and if so look at the format specified for that date field; it may be formatting it based on the outbound record definition.
Hope this helps.
Jim Cobane
Henry Ford Health
The output is actually a VRL file, and all fields are set as strings.
Min. width of 1
Max. width of -1
Since you have debugged via an echo from within your xlt proc and that shows everything to be fine, try echoing out from the xlate right after the reformatted date is copied to confirm the copy statement is or isn’t giving the desired reformatted date.
If this debug echo shows the correct outcome, then that would make me wonder if a subsequent copy might exist in your Xlate that is overwriting the desired reformatted string.
Another thought to be careful about is that if iterations are involved, be sure your copy path isn’t hardcoded and has the necessary iteration variable in the copy path defined in the xlate.
Russ Ross
RussRoss318@gmail.com
I have met the enemy..and he is me…
We have a little ‘debug’ proc and that was over-riding the changes.
😳
Now…to reformat with a ” in stead of the ‘-‘.
Been there, done that. 😛
So, if you ‘escape’ the slash, the date works as desired…
regsub {(d{4})(d{2})(d{2})} [lindex $indate 0] {2\3\1} newdate;
input: 19741010
output: 10101974
Again, thanks to all for the great hints and help.
Didn’t you want forward slashes instead of backslashes?
You can do this in one line. See Jim’s previous example.
hcitcl>set xlateOutVals
] -format %m/%d/%Y]]
07/08/2004
hcitcl>
Yes…the slashes were wrong. Figured that out…