Created
November 8, 2017 10:05
-
-
Save ateneva/ae2117f1cbfe4aff54fa5a05abea2e86 to your computer and use it in GitHub Desktop.
How do I convert string to a date with SQL?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-----------------------Vertica-------------------------------- | |
select | |
'2017-03-31' as TextField, | |
to_date('2017-03-31', 'YYYY-MM-DD') as Datefield | |
-----------------------PostgreSQL---------------------------- | |
select | |
'2017-03-31' as TextField, | |
to_date('2017-03-31', 'YYYY-MM-DD') as Datefield | |
------------------------MySQL--------------------------------- | |
select | |
'2017-03-31' as TextField, | |
str_to_date('2017-03-31', '%Y-%m-%d') as DateField | |
-----------------------SQL Server----------------------------- | |
select | |
'2017-03-31' as TextField, | |
convert(date, '2017-03-31') as DateField1, | |
cast('2017-03-31' as date) as DateField2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment