Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GETDATE() Round to Hour 1

Status
Not open for further replies.

tqeonline

MIS
Oct 5, 2009
304
US
What is an easy way to show GETDATE() but only to the hour.

I.E.
1/11/2010 13:00:00.000

- Matt

"If I must boast, I will boast of the things that show my weakness"

- Windows 2003 Server, 98 SE, XP
- VB.NET, VSTS 2010, ASP.NET, EXCEL VBA, ACCESS, SQL 2008
 
how about
Code:
Select Dateadd(hh,Datediff(hh,Convert(datetime,Convert(varchar(12),getdate())),Getdate()), Convert(datetime,Convert(varchar(12),getdate())))
 
I tried this

Code:
DateAdd(HH, DateDiff(HH, 0, GETDATE()), 0)

IT works.

- Matt

"If I must boast, I will boast of the things that show my weakness"

- Windows 2003 Server, 98 SE, XP
- VB.NET, VSTS 2010, ASP.NET, EXCEL VBA, ACCESS, SQL 2008
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top