Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi,

i want to get the date part only from datetime data type.

Please help me
Posted

Another simple solution

let DOJ be your datefield

SQL
SELECT Convert(varchar(4),DATEPART(year, DOJ)) + '/'+ Convert(varchar(2),DATEPART(MONTH, DOJ)) + '/' + Convert(varchar(2),DATEPART(DAY, DOJ))


This will give you date alone like

2010/1/22
2011/2/23

rgds
 
Share this answer
 
v2
Comments
Suraj S Koneri 17-May-12 6:14am    
For the solution u provided here s alternate method:
SELECT CONVERT(VARCHAR(10), GETDATE(), 120)
vijaylalwani 15-Jul-13 7:21am    
thanks alot
 
Share this answer
 
hi suraj,
Check this link, Hope it'll help you,

http://www.sql-server-helper.com/tips/date-formats.aspx[^]

Regards,
BlueSathish
 
Share this answer
 
SELECT CONVERT(DATE,GETDATE())
 
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