I have the following two columns in my table
callstarttime callduration
20180101215910 120
20180101215710 220
The first column's data type is varchar(255) whilst the second column is int.
What I want is to add the callduration to the callstarttime inorder to get the time which the call ended.
So I need to first convert the callstarttime column to datetime and then use the Dateadd function.
My script is as follows:
select convert(datetime, callstarttime) from Mytable
I have also tried using cast as follows
select cast(callstarttime as datetime) from Mytable
However I am getting the following error
Conversion failed when converting date and/or time from character string.
Similar questions have been asked on Convert varchar column to datetime and how to convert this varchar to datetime format?, however I can't tailor my script based on the solutions provided there.
Best Answer
Let me know how this works for you.