Data conversion
Moderators: chulett, rschirm, roy
Data conversion
Hi,
I am havin a date column of varchar .
I want to change to Date format.
my data : 3/21/2011
0001-02-02.
how can i change to date format .
Can any one have any idea?.
Thanjs & Regards
I am havin a date column of varchar .
I want to change to Date format.
my data : 3/21/2011
0001-02-02.
how can i change to date format .
Can any one have any idea?.
Thanjs & Regards
There is no "output format" here if the target is a date. So the question remains, are those two examples of what can come in as your date string?
3/21/2011
0001-02-02
So, both m/d/y & y-m-d formats in the same field? If not then please explain what you will be getting with additional examples, please.
3/21/2011
0001-02-02
So, both m/d/y & y-m-d formats in the same field? If not then please explain what you will be getting with additional examples, please.
-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:
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
The If..Then..Else construct determines which of the two formats is used in the current row. It is sufficient to test the first four characters being numeric (which indicates YYYY-MM-DD format in your case).
Code: Select all
If Num(InLink.TheString[1,4]) Then StringToDate(InLink.TheString,"%yyyy-%mm-%dd") Else StringToDate(InLink.TheString,"%m/%d/%yyyy")
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.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: