﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / T-SQL (SS2K8)  / Time - Adding minutes and seconds / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 20 Jun 2013 02:17:17 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>[quote][b]Steven Willis (3/5/2013)[/b][hr][quote][b]Sergiy (3/5/2013)[/b][hr]Whatever...[/quote]:-)[quote]These values  "10:35","14:22", etc. are from an HTML form and they are posted as strings generated by a hard-coded HTML dropdown with the 5 character pseudo-"time" values as an option item in the select input. So they are just numeric-looking character strings until someone (me) does something with them. The list of "times" is not dynamically generated as the HTML form is just a static hard-coded form. [/quote]So, there is no actually a time value sent from application.It's a string which can be parsed to a time value sent along with another string which can be parsed to a date value.It's purely you choice to store them separately, not any kind of requirement coming from the business case.Poor choice, I totally agree with Jeff here:[quote][b]Jeff Moden (12/24/2012)[/b][hr]I also have a hard time understanding why people would want to separate date and time even for display purposes unless they are, in fact, just trying to display duration.  Certainly, I wouldn't store date and time separately.[/quote][quote]Now I wrote in my post above that I know the date these values apply to, but that date (also a string since this is HTML we are talking about) needs conversion also and I COULD IF I WANTED TO concatenate the date and the times to create a well-formed datetime value but as you have correctly surmised the date itself IS stored in another column already. [/quote]Yes, as I said - it was your choice.[quote]As for the "time" column all I wanted to do was give the "times" back to the application in a manner that they would sort as time and not in ASCII sequence and allow me to determine durations between the values.[/quote]As I showed in my post, simple use of CONVERT function will allow to do just that. CONVERT is actually better as it gives better control over the formatting of output strings. [quote] I just didn't need to bother with the date-part nor did I care about the date-part since all of the time values in a particular batch ALWAYS belong to the same day. (Golfers don't have tee times that cross midnight into the next day. Maybe if the course was in the arctic I'd have to worry about that.)[/quote]You still need to know to WHICH DAY any particular tee break applies.So, you actually do need to bother with the date-part.Otherwise you would not need to store it in the database.[quote]The post was originally made to show that there are rare cases like this where the date part doesn't matter. [/quote]Turns out - your example does not show such a case.[quote]If that wasn't the case why would Microsoft have bothered creating a TIME datatype? [/quote]:-)It's not the only moronic feature MS added to the product.There must be a reason why MS designers named them "F... me nodes". [quote]I don't know what your issue is. I made an observation concerning a situation I encountered and if you never face such an issue then I guess the whole point is moot. I don't want to argue about it.[/quote]I have no issues with that.Apparently you have. :hehe:Because it's you who posted the problem which caused only by your belief that you've got a case when separating date and time in a database is a right thing to do.What was the solution to you problem?Right, concatenating date and time back together.Only "advantage" MS provided to you by introducing TIME data type is that you're gonna do concatenation every time you run a query to display the schedule or produce a report instead of doing it once when saving the data in the database.I'm not gonna use (hopefully :-P) you application, so I don't have an issue with that.As for your users - they'll have to put up with sluggish performance of the application.But they'll learn.</description><pubDate>Tue, 05 Mar 2013 17:28:28 GMT</pubDate><dc:creator>Sergiy</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>[quote][b]Sergiy (3/5/2013)[/b][hr][quote][b]Steven Willis (3/4/2013)[/b][hr]As for the time being bound to the date...well, no, not in this case. As I pointed out in the OP the data I'm getting from the application is actually in the form "10:35","14:22", etc. [/quote]Oh, really?There is no any "ConnectDate" in the same row?And you cannot tell on which day that "ConnectTime2" has happened?Sorry, I find it very hard to believe.Because when Verizon charges a customer for the calls they summarize all call durations for a month, so they have to know on which day any particular connection was established and on which day it it was ended.So please, do not tell anyone that the application stores only times with no dates. Because it's simply - not true.[/quote]Whatever...These values  "10:35","14:22", etc. are from an HTML form and they are posted as strings generated by a hard-coded HTML dropdown with the 5 character pseudo-"time" values as an option item in the select input. So they are just numeric-looking character strings until someone (me) does something with them. The list of "times" is not dynamically generated as the HTML form is just a static hard-coded form. Now I wrote in my post above that I know the date these values apply to, but that date (also a string since this is HTML we are talking about) needs conversion also and I COULD IF I WANTED TO concatenate the date and the times to create a well-formed datetime value but as you have correctly surmised the date itself IS stored in another column already. As for the "time" column all I wanted to do was give the "times" back to the application in a manner that they would sort as time and not in ASCII sequence and allow me to determine durations between the values. I just didn't need to bother with the date-part nor did I care about the date-part since all of the time values in a particular batch ALWAYS belong to the same day. (Golfers don't have tee times that cross midnight into the next day. Maybe if the course was in the arctic I'd have to worry about that.)The post was originally made to show that there are rare cases like this where the date part doesn't matter. If that wasn't the case why would Microsoft have bothered creating a TIME datatype? I don't know what your issue is. I made an observation concerning a situation I encountered and if you never face such an issue then I guess the whole point is moot. I don't want to argue about it. </description><pubDate>Tue, 05 Mar 2013 16:28:32 GMT</pubDate><dc:creator>Steven Willis</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>[quote][b]Steven Willis (3/4/2013)[/b][hr]As for the time being bound to the date...well, no, not in this case. As I pointed out in the OP the data I'm getting from the application is actually in the form "10:35","14:22", etc. [/quote]Oh, really?There is no any "ConnectDate" in the same row?And you cannot tell on which day that "ConnectTime2" has happened?Sorry, I find it very hard to believe.Because when Verizon charges a customer for the calls they summarize all call durations for a month, so they have to know on which day any particular connection was established and on which day it it was ended.So please, do not tell anyone that the application stores only times with no dates. Because it's simply - not true.</description><pubDate>Tue, 05 Mar 2013 15:44:07 GMT</pubDate><dc:creator>Sergiy</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>Sergiy, you make some good points. However, in my original post I wasn't particularly concerned with the excess of zeroes because like you said, it's better that the UI handle that formatting function and in this application it does.As for the time being bound to the date...well, no, not in this case. As I pointed out in the OP the data I'm getting from the application is actually in the form "10:35","14:22", etc. The column of times is part of a set of data for just one particular day so that date is displayed elsewhere and is not connected to the tee time column (though it could be concatenated into a datetime if it was necessary which in this case it wasn't).The only reason I even needed to use a date/time-related datatype conversion at all was for sorting purposes and for calculating a duration--and that there are major differences between SQL2005 and SQL2008 when trying to do that. Pointing out these differences was really all I was trying to demonstrate.But believe me that I'm not trying to be defensive or snippy. Feedback is always appreciated. Iron sharpens iron. ;-) </description><pubDate>Mon, 04 Mar 2013 19:13:10 GMT</pubDate><dc:creator>Steven Willis</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>[quote][b]Steven Willis (1/2/2013)[/b][hr]The output was for a golf tournament signup schedule and the end-user needed a column to display tee times. These were actual times of course and not durations. The day date was on the page showing the tee times [b][u]for that day[/u][/b]. I'd think this might apply as well to any scheduling situation such as at a doctor's office, etc. [/quote]From the part of you statement I highlighted above it's obvious you still need to know on which day any particular time will be used.Time is still bound to date, and it's totally irrelevant if disconnected.What you are describing is a presentation issue, and it must be dealt with on UI, not in databse.I do not see you are using TIME datatype to solve any other issue than presentation format.And DATYTIME is still easier to use here."Date" portion of any datetime value defines if this time to be displayed on the page for the selected date.When you display some events for a day you include all date-time values which fall in between of beginning of the day and end of the day.When you display events for an afternoon you include all date-time events between midday of the day and end of the day.          Now, try to do it with separate date and time! You'll have to bring date and time together into a datetime value and work it out from there.And the format of the "time" portion displayed on the page is better defined by using CONVERT to string data types (varchar, nvarchar, etc.) rather than to TIME (I'm pretty sure users won't be happy to see on UI all those trailing zeros showed in your examples).[code="sql"]DECLARE @TeeTime DATETIMESET @TeeTime = '14:22'SELECT CONVERT(char(8), @TeeTime, 8) AS TeeTime--&amp;gt; Output: 14:22:00SELECT CONVERT(char(5), @TeeTime, 8) AS TeeTime--&amp;gt; Output: 14:22 [/code]Very nice display, much better than from using implicit conversions from TIME data type.Same logic applies to inserting a time.When setting up a time you have you date selected, and you effectively are setting date-time, not time only.Bind date and time parts of the event on the way from UI to database as save it as it should be saved - datetime value.You mentioned "doctor's office" as an example. I wonder - how many times did you hear about a doctor's appointment set up for a time without specifying a date?Would you be happy to check on doctor's office every day to find if the appointment time you've got is for today actually?:hehe:</description><pubDate>Mon, 04 Mar 2013 18:10:42 GMT</pubDate><dc:creator>Sergiy</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>[quote][b]Lynn Pettis (1/27/2010)[/b][hr]Like this?[code="sql"]declare @ TimeVal time,        @ TotalTime time;  -- space added between @ and variable name to allow code to postset @TimeVal = '08:05:44.0000000';set @TotalTime = '00:13:00.0000000'select  @TimeVal,        @TotalTime,        dateadd(ss, ((DATEPART(HOUR,@TotalTime) * 60) + DATEPART(MINUTE,@TotalTime) * 60) + DATEPART(SECOND,@TotalTime), @TimeVal),        @TimeVal + @TotalTime;[/code] i'm also doing something similar as to what you did here above but in my case i would like to know from you if it is possible to replace [b]@TimeVal = '08:05:44.0000000';[/b] with [b]@TimeVal = [RefreshIntervalColumn][/b]Because in my case is every records interval time is different, how do i go about it....this is what im using  [b]DATEADD(s, RefreshIntervalSeconds, GETDATE())[/b]</description><pubDate>Mon, 04 Mar 2013 07:14:23 GMT</pubDate><dc:creator>islater88</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>[quote][b]Jeff Moden (12/24/2012)[/b]...I also have a hard time understanding why people would want to separate date and time even for display purposes unless they are, in fact, just trying to display duration. ...[/quote]Jeff, for what it's worth, I had a requirement to do a query a few weeks ago that only displayed the time part (and formatted as AM/PM too). The spec required that the date part NOT be displayed. The output was for a golf tournament signup schedule and the end-user needed a column to display tee times. These were actual times of course and not durations. The day date was on the page showing the tee times for that day. I'd think this might apply as well to any scheduling situation such as at a doctor's office, etc.In my case, the "date" values coming from the application source for that column were in the form "10:35","14:22", etc. And the user's SQL version was 2005 so the TIME datatype was unavailable! I discovered though that the DATETIME datatype accepts input such as "14:22" as is and merely converts it to "1900-01-01 14:22:00.000". I considered trying to put in the actual date, but since there was this implicit conversion and the day date was stored in another date column (bad design? yeah!), I just used it as is.Examples: [code="sql"]--SQL 2005DECLARE @TeeTime DATETIMESET @TeeTime = '14:22'SELECT @TeeTime AS TeeTime--&amp;gt; Output: 1900-01-01 14:22:00.000[/code][code="sql"]--SQL 2008DECLARE @TeeTime1 TIMESET @TeeTime1 = '14:22'SELECT @TeeTime1 AS TeeTime--&amp;gt; Output: 14:22:00.0000000[/code]Getting durations:[code="sql"]DECLARE @Time1 TIMESET @Time1 = '14:22'DECLARE @Time2 TIMESET @Time2 = '14:28'SELECT @Time2-@Time1 AS TimeDuration--&amp;gt; Output: error: 'Operand data type time is invalid for subtract operator.'[/code][code="sql"]DECLARE @Time3 DATETIMESET @Time3 = '14:22'DECLARE @Time4 DATETIMESET @Time4 = '14:28'SELECT CAST(@Time4-@Time3 AS TIME) AS TimeDuration--&amp;gt; Output: 00:06:00.0000000[/code]Adding time to get a new time:[code="sql"]DECLARE      @Time5 TIME    ,@TimeInterval1 TIMESET @Time5 = '14:22'SET @TimeInterval1 = '00:06'SELECT @Time5+@TimeInterval1 AS NextTime--&amp;gt; Output: error: 'Operand data type time is invalid for add operator.'[/code][code="sql"]DECLARE      @Time6 DATETIME    ,@TimeInterval2 DATETIME    SET @Time6 = '14:22'SET @TimeInterval2 = '00:06'SELECT CAST(@Time6+@TimeInterval2 AS TIME) AS NextTime--&amp;gt; Output: 14:28:00.0000000[/code] </description><pubDate>Wed, 02 Jan 2013 10:32:10 GMT</pubDate><dc:creator>Steven Willis</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>[quote][b]Jeff Moden (12/29/2012)[/b][hr][quote][b]dwain.c (12/25/2012)[/b][hr][quote][b]Jeff Moden (12/25/2012)[/b][hr]Merry Christmas Dwain.[/quote]Let me see.  Christmas morning where you are and here you are posting on the SSC forum.You must want that 32,000th post pretty bad![/quote]Nah... number of posts is a nice badge but that's not why I post.  SQL isn't only my job, it's a hobby.  Some folks do Sudoku, cross word puzzles, video games, etc... I like figuring out SQL problems.[/quote]Me too!  :cool:Happy New Year to you Jeff (and everybody else on this thread)! :hehe:</description><pubDate>Tue, 01 Jan 2013 03:32:35 GMT</pubDate><dc:creator>dwain.c</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>[quote][b]dwain.c (12/25/2012)[/b][hr][quote][b]Jeff Moden (12/25/2012)[/b][hr]Merry Christmas Dwain.[/quote]Let me see.  Christmas morning where you are and here you are posting on the SSC forum.You must want that 32,000th post pretty bad![/quote]Nah... number of posts is a nice badge but that's not why I post.  SQL isn't only my job, it's a hobby.  Some folks do Sudoku, cross word puzzles, video games, etc... I like figuring out SQL problems.</description><pubDate>Sat, 29 Dec 2012 10:42:40 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>[quote][b]Jeff Moden (12/25/2012)[/b][hr]Merry Christmas Dwain.[/quote]Let me see.  Christmas morning where you are and here you are posting on the SSC forum.You must want that 32,000th post pretty bad!</description><pubDate>Tue, 25 Dec 2012 07:50:25 GMT</pubDate><dc:creator>dwain.c</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>Merry Christmas Dwain.</description><pubDate>Tue, 25 Dec 2012 07:46:05 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>+100% (agreement).  Merry Christmas Jeff!</description><pubDate>Mon, 24 Dec 2012 17:35:50 GMT</pubDate><dc:creator>dwain.c</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>No, no.... you were spot on.  TIME columns are ok for durations of 1 day but aren't actually duration columns.  I also have a hard time understanding why people would want to separate date and time even for display purposes unless they are, in fact, just trying to display duration.  Certainly, I wouldn't store date and time separately.I might store just the date if it's a column guaranteed to only ever need to be a whole date but then there's the problem of doing nasty little conversions like the one on this thread.  For example, you asked if I was suggesting the following...2012-12-21 05:00 + 2012-12-24 07:00If the second date/time is supposed to be the duration and the first date/time is the start date, then kind of but not quite.  If someone worked 1 hour, 13 minutes, and 59 seconds, then any of the following would work just fine to get the EndDate...2012-12-21 05:00 + '01:13:59'2012-12-21 05:00 + '1900-01-01 01:13:59' --Admittedly, confusing, but shows how things work.StartDate + Duration -- Where both are data/time datatypes and the duration is stored as a result of (for example) '1900-01-01 01:13:59' .Yeah... I know this stuff doesn't work for any of the "new" date/time datatypes.  I think that MS really  and unnecessarily made it a whole lot more difficult to do such simple things as adding a simple duration to a starting date and time.  I wish they would have (no pun intended) spent the time making a proper "Duration" datatype that would allow you to store a (for example) 49 hour duration as something a little easier for folks to figure out other than 1900-01-03 01:00:00.  For example, the following DOESN"T currently work... SELECT Duration = CAST('49:00:00' AS DATETIME)Instead, you have to go through a bunch of hooie to parse the hours, minutes, and seconds and then DATEADD each of those back to "0" (1900-01-01).Same goes the other way around.  Using subtraction between a start and end date/time is easy and accurate even across years.  With the new date/time data types, you have to do something stupid like doing a DATEDIFF in milliseconds and then a DATEADD to "0" to reconvert it back to a date/time data type.</description><pubDate>Mon, 24 Dec 2012 06:33:40 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>[quote][b]Jeff Moden (12/23/2012)[/b][hr]What I'm actually trying to get people to realize is that using JUST the time for this type of stuff (EndTime = StartTime + Duration) is the wrong thing to do unless it's ok to "wrap the clock" after midnight.  If you have a duration that exceeds 24 hours starting just before midnight of one day, then you really need to show that the call or whatever duration your trying to portray ended two days later just after midnight.In other words, both StartTime and EndTime must show the date AND the time for both.[/quote]Of course.  Sorry Jeff, I didn't mean to speak for you.But of interest, what is the meaning in the physical world of the following addition?2012-12-21 05:00 + 2012-12-24 07:00If your answer is that you're adding the number of days between Jan 1, 1900 and Dec 12, 2012 (+ 7 hours) to the date Jan 21, 2012 (at 5AM), I'm with you.  I'm just saying it's a kludge (albeit a widely used one).  Because MS hasn't been so kind to provide a specific type for a date/time interval.Personally, my preference is to use the DATETIME to hold the date and an INT (or BIGINT) to hold the minutes, or if need be seconds, to represent the interval.  Ignoring for the moment the issues you might encounter using BIGINT.</description><pubDate>Sun, 23 Dec 2012 23:49:04 GMT</pubDate><dc:creator>dwain.c</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>What I'm actually trying to get people to realize is that using JUST the time for this type of stuff (EndTime = StartTime + Duration) is the wrong thing to do unless it's ok to "wrap the clock" after midnight.  If you have a duration that exceeds 24 hours starting just before midnight of one day, then you really need to show that the call or whatever duration your trying to portray ended two days later just after midnight.In other words, both StartTime and EndTime must show the date AND the time for both.</description><pubDate>Sun, 23 Dec 2012 22:39:25 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>[quote][b]Jeff Moden (12/22/2012)[/b][hr][quote][b]neevmansoori (12/22/2012)[/b][hr]We sincerely thank you..It Saves a lot of Efforts of mine.:-)[/quote]Yeah, but as old as this post is, I'm not sure that it answers what needs to be done for display purposes if the following data is present...Connect Time2 totalTime223:00:00.0000000 01:00:00.0000000[/quote]I think what Jeff is alluding to without saying it is the TIME data type is a "time of day" and not a "time duration."  Adding them together implies that at least one of the values is a "time duration."  How can you add 4PM + 6PM?Perhaps though, it has some meaning in another multiverse.</description><pubDate>Sun, 23 Dec 2012 17:47:17 GMT</pubDate><dc:creator>dwain.c</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>[quote][b]neevmansoori (12/22/2012)[/b][hr]We sincerely thank you..It Saves a lot of Efforts of mine.:-)[/quote]Yeah, but as old as this post is, I'm not sure that it answers what needs to be done for display purposes if the following data is present...Connect Time2 totalTime223:00:00.0000000 01:00:00.0000000</description><pubDate>Sat, 22 Dec 2012 10:40:56 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>We sincerely thank you..It Saves a lot of Efforts of mine.:-)</description><pubDate>Sat, 22 Dec 2012 08:01:39 GMT</pubDate><dc:creator>neevmansoori</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>Nevermind!  I figured it out![code="sql"]declare @ TimeVal time,        @ TotalTime time;  -- space added between @ and variable name to allow code to postset @TimeVal = '08:05:44.000';set @TotalTime = '00:13:00.000';select  @TimeVal,        @TotalTime,        dateadd(ss, ((DATEPART(HOUR,@TotalTime) * 60) + DATEPART(MINUTE,@TotalTime) * 60) + DATEPART(SECOND,@TotalTime), @TimeVal),        convert(time, (convert(datetime, @TimeVal, 108) + convert(datetime, @TotalTime, 108)), 108);[/code]</description><pubDate>Wed, 27 Jan 2010 13:12:16 GMT</pubDate><dc:creator>Lynn Pettis</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>Like this?[code="sql"]declare @ TimeVal time,        @ TotalTime time;  -- space added between @ and variable name to allow code to postset @TimeVal = '08:05:44.0000000';set @TotalTime = '00:13:00.0000000'select  @TimeVal,        @TotalTime,        dateadd(ss, ((DATEPART(HOUR,@TotalTime) * 60) + DATEPART(MINUTE,@TotalTime) * 60) + DATEPART(SECOND,@TotalTime), @TimeVal),        @TimeVal + @TotalTime;[/code]I get the following error:[code="plain"]Msg 8117, Level 16, State 1, Line 6Operand data type time is invalid for add operator.[/code]</description><pubDate>Wed, 27 Jan 2010 13:05:05 GMT</pubDate><dc:creator>Lynn Pettis</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>Ah... sorry Wayne... didn't see your post which is the same as what I just suggested.</description><pubDate>Wed, 27 Jan 2010 13:02:59 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>I know the problem has already been solved but DATEADD isn't the solution you need here because that requires that you do split the data into its various time components.  All you need to do is convert the date and time columns to the DATETIME datatype and add them together using a plain ol' "+" sign.After that, format the result the way you want it.</description><pubDate>Wed, 27 Jan 2010 13:00:23 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>Thanks so much everyone!</description><pubDate>Wed, 27 Jan 2010 11:26:28 GMT</pubDate><dc:creator>tan110</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>You are so Awesome! Lynn. Thank very much.</description><pubDate>Wed, 27 Jan 2010 11:26:03 GMT</pubDate><dc:creator>tan110</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>This should do the trick:[code="sql"]-- note how this starts off by creating a table structure and putting data into it?-- In order to get people willing to help, this is a prerequisite on your part.-- see the link in my signature for how to do this.declare @VerizonDetails table ([Connect Time2] TIME, [totalTime2] TIME)insert into @VerizonDetailsvalues ('08:05:44.0000000', '00:13:00.0000000'),       ('08:05:57.0000000', '00:01:00.0000000'),       ('09:07:42.0000000', '00:03:00.0000000'),       ('09:07:46.0000000', '00:09:00.0000000'),       ('09:08:08.0000000', '00:01:00.0000000')-- add the two times together, first converting them to datetimesselect *, convert(time, CONVERT(datetime, [Connect Time2]) + CONVERT(datetime, totalTime2))  from @VerizonDetails[/code]</description><pubDate>Wed, 27 Jan 2010 11:25:08 GMT</pubDate><dc:creator>WayneS</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>Does the following help?[code="sql"]declare @ TimeVal time,           @ TotalTime time; -- spaces between @ and rest of variable names to allow posting of codeset @TimeVal = '08:05:44.0000000';set @TotalTime = '00:13:00.0000000'select @TimeVal, @TotalTime, dateadd(ss, ((DATEPART(HOUR,@TotalTime) * 60) + DATEPART(MINUTE,@TotalTime) * 60) + DATEPART(SECOND,@TotalTime), @TimeVal);[/code]</description><pubDate>Wed, 27 Jan 2010 11:23:10 GMT</pubDate><dc:creator>Lynn Pettis</dc:creator></item><item><title>RE: Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>Go to BOL and look up DATEADD.I just looked it up myself.  You're going to need to split the hours, minutes, and seconds to use DATEADD (this can be done using time functions such as HOUR, MIN, etc.).</description><pubDate>Wed, 27 Jan 2010 11:14:50 GMT</pubDate><dc:creator>Ray K</dc:creator></item><item><title>Time - Adding minutes and seconds</title><link>http://www.sqlservercentral.com/Forums/Topic854581-392-1.aspx</link><description>I have the 2 columns with time datatypes.select top 5 [Connect Time2],[totalTime2] from dbo.verizonDetailsConnect Time2	        totalTime208:05:44.0000000	00:13:00.000000008:05:57.0000000	00:01:00.000000009:07:42.0000000	00:03:00.000000009:07:46.0000000	00:09:00.000000009:08:08.0000000	00:01:00.0000000I want to add the time from totalTime2 to column [Connect Time2]. The desired result to look like this:Connect Time2	        totalTime2                endTime08:05:44.0000000	00:13:00.0000000      08:18:44.000000trying to run the following:select top 5 [Connect Time2],[totalTime2], ([Connect Time2] + [totalTime2]) as endTimefrom dbo.verizonDetailsbut getting error:Operand data type time is invalid for add operator.</description><pubDate>Wed, 27 Jan 2010 11:06:56 GMT</pubDate><dc:creator>tan110</dc:creator></item></channel></rss>