Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,

Can any one tell me how to Trim long INT value to date.

i have
SQL
"1- 240320141568"
to
SQL
'24-03-2014'


thanks in advance..
Posted
Comments
syed shanu 25-Mar-14 1:28am    
Chk this Link
http://stackoverflow.com/questions/3855867/convert-int-to-datetime-sql

http://www.sqlteam.com/forums/topic.asp?topic_id=108759

i solved it, have a look,

here is int:
1 - 240320141568

SQL
SUBSTRING('FeildName',CHARINDEX('-','FeildName')+3,LEN('FeildName'))


the above Query Returns 240320141568

now
SQL
SUBSTRING('FeildName',CHARINDEX('-','FeildName')+3,10)

this will return
24032014 which can be converted into date using CAST
.. :-)
 
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