Geoffrey Emery
Tech Goodness

T-Sql Seperate Date and Time

April 23, 2008 21:36 by gemery

I just used this for the 1000th time so I thought i would blog about it. Just replace getdate() and with your date...

-- just the date
SELECT CONVERT(char(10), getdate(), 101) AS [Date]
SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))
-- just the time
SELECT (getdate() - 
    CAST(ROUND(CAST(getdate() AS float), 0, 1) AS datetime))
SELECT CONVERT (datetime, (1 - (CONVERT (float, getdate() ) - 
     CONVERT (int, CONVERT (float, getdate())))) * - 1 - 1)

Tags:
Categories: SQL Server | T-SQL
Actions: E-mail | Permalink | Comments (8) | Comment RSSRSS comment feed

Related posts

Comments

August 26. 2008 08:09

Vadivel P.

I had Used the Following Code to get Only Date

Declare @MyDate varchar(12)
set @MyDate = cast (getdate() as smalldatetime )
select cast(@myDate as datetime)
select @MyDate

It is Working for Me.

Vadivel P.

October 13. 2008 09:28

Antony Koch

Equally,

select convert(nvarchar(10), getdate(), 103)

can be used (103 being UK date formatting)

Antony Koch

September 26. 2009 04:35

Giocare ai giochi dei casinò

This article gives the light in which we can observe the reality. this is very nice one and gives in depth information. thanks for this nice article Good post.....Valuable information for all.I will recommend my friends to read this for sure…

Giocare ai giochi dei casinò

November 1. 2009 00:03

personal loans

Do you make money out of this blog? just curious

personal loans

November 5. 2009 05:34

payday loans

Interesting post

payday loans

November 9. 2009 12:43

fast payday loans

Searching for this for some time now - i guess luck is more advanced than search engines Smile

fast payday loans

November 10. 2009 02:59

payday loans

Thank you for your help!

payday loans

November 10. 2009 04:43

sell gold coins Houston

This is such a great resource that you are providing and you give it away for free. I love seeing websites that understand the value of providing a quality resource for free. It is the old what goes around comes around routine. Did you acquired lots of links and I see lots of trackbacks??

sell gold coins Houston

Comments are closed