Add or subtract time in SQL Server

I have a time in format 08:40
i ll like to add or subtract 60 minutes to that time in sql server

08:40 + sixty munites
08:40 - sixty munites
peterslove53Asked:
Who is Participating?
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Use DATEADD

Declare @time time = '08:40'
SELECT DATEADD(hour, -1, @time), DATEADD(hour, 1, @time)

Open in new window

0
 
AielloJCommented:
peterslove53:

Is your starting time (08:40) in a date or time format, or text?

AielloJ
0
 
peterslove53Author Commented:
time is just an int
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
>I have a time in format 08:40
>time is just an int
Explain for us how the value '08:40' can be assigned to an int data type.
0
 
peterslove53Author Commented:
its data type "Time"
0
 
AielloJCommented:
peterslove53:

If it's type "time", then Jim Horn's initial response should do what you want.

AielloJ
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.