Click here to Skip to main content
15,301,841 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
   
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
Try:
SQL
SELECT CONVERT(VARCHAR(10),GETDATE(),111)


Details here:
MSDN: CAST and CONVERT (Transact-SQL)[^]
SQL SERVER – Retrieve – Select Only Date Part From DateTime – Best Practice[^]
   
hi suraj,
Check this link, Hope it'll help you,

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

Regards,
BlueSathish
   
SELECT CONVERT(DATE,GETDATE())
   

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