Microsoft SQL 2005 -- datetime, remove 1 hour ?

finance_teacher
finance_teacher used Ask the Experts™
on
Below "[DateTime] - 1" gets the database
record's value and removes one day,
therefore 2015-08-07 11:47:06.000
becomes 2015-08-06 11:47:06.000

How can I change
to remove one hour instead,
therefore 2015-08-07 11:47:06.000
becomes 2015-08-07 10:47:06.000 ?

============================================

SELECT [ID]
      ,[DateTime] - 1
      ,[Type]
      ,[BadgeID]
FROM ...........
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Developer
Commented:
DATETIME arithmetics: days.hours. Thus one hour is 1/24. Or use DATEADD():

SELECT  GETDATE() ,
        GETDATE() - 1 / 24.0 ,
        DATEADD(HOUR, -1, GETDATE());

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial