Hello,
I am trying to convert 1/1/2014 to 2014-01-01. Any suggestions. I tried this but output to file has all ***
DatetoString(stringtodate(DSLink9.DT,"%mm/%dd/%yyyy"),"%yyyy-%mm-%dd")
Thanks
Date conversion from 1/1/2014 to 2014-01-01
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 236
- Joined: Sun Apr 01, 2007 7:41 am
- Location: Michigan
-
- Premium Member
- Posts: 236
- Joined: Sun Apr 01, 2007 7:41 am
- Location: Michigan
Probably didn't really "work work" as "2014-01-01" isn't a date but rather a string. So what you posted as working would be fine if the actual target data type is a DATE (which is why you only would need the format for the input string) or the original post would be close to what you would need to convert from one string to another using those two different formats.
You'll also find it will work for "1/1/2014" but not "01/01/2014" or "10/1/2014) but perhaps that's not a concern in your specific scenario.
You'll also find it will work for "1/1/2014" but not "01/01/2014" or "10/1/2014) but perhaps that's not a concern in your specific scenario.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Format string "%m/%d/%yyyy" is not a good general solution. It's OK if you are only dealing with the first day of the month, but fails when the number of digits in the day or month reaches two.
Search DSXchange or review the documentation for a format string that will handle one- or two-digit date components.
Search DSXchange or review the documentation for a format string that will handle one- or two-digit date components.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.