I have a date field that is pulling from a server as just an 8 digit number, and I would like to convert it to a standard date format.
For example, " 20140501
" would be converted to 05-01-2014
I tried using the DateTime
code, but that didn't work for me. Any suggestions?
Many databases might recognize the string '20140501' as a date, because this is an ISO standard format. Hence, you might try this:
select cast(cast(datecol as varchar(255)) as date)
Whether or not this works depends on your database.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.