January 26, 2017 at 10:57 am
Hello All,
I'm stuck at a point where I'm unable to convert the below char to Datetime format. can someone help me get through this. then i'll all be golden in my ETL.
Char to be converted: '2017/01/26:08:13:55'
Expected format is DateTime.
January 26, 2017 at 11:06 am
Mac1986 - Thursday, January 26, 2017 10:57 AMHello All,
I'm stuck at a point where I'm unable to convert the below char to Datetime format. can someone help me get through this. then i'll all be golden in my ETL.
Char to be converted: '2017/01/26:08:13:55'
Expected format is DateTime.
If this is how all the dates are represented in character form, the first thing you need to do is replace that ":" between the date and time with a space. After doing that the string should convert. To be sure I would also replace the "/" with a "-".
January 26, 2017 at 12:13 pm
Mac1986 - Thursday, January 26, 2017 10:57 AMHello All,
I'm stuck at a point where I'm unable to convert the below char to Datetime format. can someone help me get through this. then i'll all be golden in my ETL.
Char to be converted: '2017/01/26:08:13:55'
Expected format is DateTime.
Thanks for the tip. I used below conversion.
SELECT CAST(SUBSTRING('2017/01/26:08:13:55',1,10) + ' ' + SUBSTRING('2017/01/26:08:13:55',12,19) AS datetime)
January 26, 2017 at 12:20 pm
Lynn Pettis - Thursday, January 26, 2017 11:06 AMMac1986 - Thursday, January 26, 2017 10:57 AMHello All,
I'm stuck at a point where I'm unable to convert the below char to Datetime format. can someone help me get through this. then i'll all be golden in my ETL.
Char to be converted: '2017/01/26:08:13:55'
Expected format is DateTime.If this is how all the dates are represented in character form, the first thing you need to do is replace that ":" between the date and time with a space. After doing that the string should convert. To be sure I would also replace the "/" with a "-".
There are several formats which are independent of any language settings. Read more about those in here: https://technet.microsoft.com/en-us/library/ms180878%28v=sql.105%29.aspx#UsingDateandTimeFormats
For dates only:
For time only:
For date and time:
That being said, I prefer to remove the "-" to keep some consistency.
To achieve this formats, REPLACE and STUFF will be of great help.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply