Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sql Convert Text Field To Date Field

Tags:

sql

ms-access

I'm importing an access database to sql.

The original access database has a date field that imports nicely, but the time field is text (10:00 AM, for instance).

I have over 4000 records and assume there is a way to convert 10:00 AM to 10:00:00.000 (or 07:30 PM to 19:30:00.000, etc...) so that it can be combined with the pre-existing date field (which is now like 2011-11-11 00:00:00.000).

Also, if it's easy to do the conversion and concatenation in the same process, please note.

like image 747
doubleJ Avatar asked Sep 02 '26 13:09

doubleJ


1 Answers

to convert the time from am or pm 10:00 PM format into time format 10:00:00.000:

select cast(timestring as time(7))
like image 115
Mahmoud Gamal Avatar answered Sep 05 '26 02:09

Mahmoud Gamal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!