December 15, 2008 at 9:33 am
I need a simple sql statement with a case to determine whether 2 times need to be added or subtracted
the case statement i have works... but sql wont allow me to subtract or add the 2 timespan datatypes.
the case statement reads
ok the statement reads:
CASE WHEN dbo.Races.rSealed = 0 THEN (dbo.Results.rTime - dbo.Results.rHandicap) ELSE (dbo.Results.rTime + dbo.Results.rHandicap)
END AS 'Actual Time'
the data types are both time(4)
the error is:
Operand data type time is invalid for subtract operator.
ive been searching everywhere...even guidance on what to read would be appreciated
December 15, 2008 at 9:55 am
Michael Artz (12/15/2008)
I need a simple sql statement with a case to determine whether 2 times need to be added or subtractedthe case statement i have works... but sql wont allow me to subtract or add the 2 timespan datatypes.
the case statement reads
ok the statement reads:
CASE WHEN dbo.Races.rSealed = 0 THEN (dbo.Results.rTime - dbo.Results.rHandicap) ELSE (dbo.Results.rTime + dbo.Results.rHandicap)
END AS 'Actual Time'
the data types are both time(4)
the error is:
Operand data type time is invalid for subtract operator.
ive been searching everywhere...even guidance on what to read would be appreciated
Please read the article below in my signature block regarding how to ask for help. What would really help here is the DDL for the table, some sample data for the table, expected results based on the sample data, and the complete code you are currently using. The article below actually tells you step by step how to put all of this together for posting so that you get the best answer in response.
December 15, 2008 at 9:58 am
Duplicate post. Please post answers here
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
December 15, 2008 at 10:00 am
Are you sure it shouldn't be posted here instead of there? One post is in SQL Server 2005 and the other is SQL Server 2008. In the other post, I asked what version of SQL he is using.
December 15, 2008 at 10:05 am
Lynn Pettis (12/15/2008)
Are you sure it shouldn't be posted here instead of there? One post is in SQL Server 2005 and the other is SQL Server 2008. In the other post, I asked what version of SQL he is using.
I don't know, I just gave an answer in the other one and didn't want to see it repeated. He does mention the timespan data type which isn't a data type in 2005.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
December 15, 2008 at 10:17 am
Good thing I didn't tell people to post here instead in the other thread. At this point, I just want to know what version of SQL is being used.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply