Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I need to convert the date eg.12/1/2014 into 1 in sql. Any suggestions please?
Posted
Updated 5-Feb-14 23:59pm
v2
Comments
Pete O'Hanlon 6-Feb-14 5:59am    
What datatype is this value in SQL? Is it a Date or DateTime - or is it a string?
prabhatsp 6-Feb-14 6:00am    
varchar

1 solution

You need to convert the string into the correct format DATETIME and then you can retrieve the day:
SQL
SELECT DAY(CONVERT(DATETIME, '12/1/2014', 101))
 
Share this answer
 
Comments
prabhatsp 6-Feb-14 6:07am    
thank u a lot
Pete O'Hanlon 6-Feb-14 6:15am    
You are welcome. I'm glad that I could help.

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