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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datetime computation

Status
Not open for further replies.

rtdvoip

Programmer
Aug 29, 2003
27
US
I have just started learning sql and although I have books
a good example is not available for my current question.
Please help....

I have a duration of type int in seconds
I have a start_time of type datetime

how do i compute the end_time of type datetime
using the start_time and duration?

any suggestions?

thanks,
rtdvoip
 
Check out DateDiff in Books On-Line
DateDiff(ss, <startdatetime>, <enddatetime>)

JHall
 
First step is, look up DATEADD in Books Online, to get the whole syntax. But, basically DATEADD is what you need. If, for example, you wanted to add 2 hours to start_time, you would say:
Code:
end_time = DATEADD(hh, 2, start_time)
 
And for seconds,
Code:
end_time = DATEADD(ss, duration, start_time)
 
Once again I assumed something wrong, sorry, thought you wanted to calculate the duration.

JHall
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top