.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> SQL Query >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

SQl Query For Getting Only Date Part

Posted By:Ravi Ranjan Kumar       Posted Date: June 09, 2011    Points: 40    Category: SQL Query    URL: http://www.dotnetspark.com  

This Query enable you to get only DataPart without using Convert.
 

Here some Code for getting only DateTimePart while query about current date time

SELECT 
    CAST( FLOOR( CAST( getDate() AS FLOAT ) ) AS DATETIME )
or 

select Dateadd(dd,0,datediff(dd,0,getdate()))
or

Select CAST(cast( GETDATE() AS INT ) AS DATETIME)
or you can also use another alternate way 

select cast(cast(getdate() as varchar(11)) as datetime)



Out put will be :- 
2011-06-09 
instead of 
2011-06-09 21:57:23.947.


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend