Brogrim
asked on
Convert Date Function
I have a table that is varchar but always starts with 2013-01-01 00:00:00 so I want to convert the varchar to a date
I ma trying to use the
select convert(IssueDate, (101)) from tblpermit
any suggestions? am i even using the correct function
I ma trying to use the
select convert(IssueDate, (101)) from tblpermit
any suggestions? am i even using the correct function
You aren't telling it what you want to convert to. ie:
Edit: You may have to play with this a bit, since I assumed you were trying to convert the value of what's in the IssueDate column, but after seeing EvilPostIt's take, i see it was kind of up in the air. (and 101's mm/dd/yyyy =)
select convert( date, IssueDate, 101 ) as convertedIssueDate from tblpermit;
Edit: You may have to play with this a bit, since I assumed you were trying to convert the value of what's in the IssueDate column, but after seeing EvilPostIt's take, i see it was kind of up in the air. (and 101's mm/dd/yyyy =)
select convert(varchar, IssueDate, 101) from tblpermit
There would be no difference between using the column name or the string. If the month is the other way round you may have to set the language.
ASKER
select convert(varchar, IssueDate, 101) from tblpermit
returned
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'varchar, PermitIssueDate, 101) from tblpermit' at line 1
returned
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'varchar, PermitIssueDate, 101) from tblpermit' at line 1
ASKER
getting the same error for all suggestions
So your using mySQL not SQL Server then...
Look at the DATE_FORMAT function
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format
ASKER
should have mentioned that, apoligies.
MySQL
MySQL
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thank you
Open in new window