Click here to Skip to main content
15,885,954 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have table which store the date in yyyymmdd and it is a integer field i want to convert it to mm-dd-yyyy format.can any one help me???
Posted
Comments
Maarten Kools 10-Mar-14 9:22am    
Why is a date stored as an integer? Why wasn't a DATETIME[^] data type used instead?

Anyway, convert the integer to a string and then retrieve the appropriate substrings to format it in the proper way.
Sandip Paul 491984 10-Mar-14 9:26am    
actually i got a project in which i have to change the existing data to new format.The old data have the data format as yyyymmdd format and i need to change it to mm-dd-yyyy before redesign the application

1 solution

SQL
DECLARE @intDatetime int = 20140327
DECLARE @strDatetime VARCHAR(10) = convert(varchar(10),@intDatetime)
SELECT 'Date time in MM/dd/yyyy Format' = convert(VARCHAR(10),convert(datetime,@strDatetime),101)

Happy Coding!
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900