First post/question here. I'm trying to convert an nchar to datetime. The examples I looked for all displayed converting to 12 hour from 24 or just dealing with time and not the full date with conversion. I'm not a native to SQL and I'm still learning the basics, so any help is appreciated.
I have a table with this format that I've read from a bulk insert of .txt files.
Alarm is nchar of text,
AlarmTime is also nchar of the date I read from the text file.
Alarm | AlarmTime
1 | 7/6/2016 10:10:42 AM
2 | 7/10/2016 6:41:23 PM
3 | 8/4/2016 4:35:53 PM
I would like to get this into a datetime format and not be store as nchar. Whenever I try to convert I get an error: Conversion failed when converting date and/or time from character string.
The result I'm looking for is this just stored as datetime:
Alarm | AlarmTime
1 | 7/6/2016 10:10:42
2 | 7/10/2016 18:41:23
3 | 8/4/2016 16:35:53
I have considered separating the date and time in to separate columns using a delimiter and then putting them both back together later. Or using the PM to add time then convert the colum to datetime. But those both seemed cumbersome, and I figured there was something easy I was missing to accomplish this.
Thanks in advance!