Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Mulitply Time * Money field

Author  Topic 

ConfusedAgain
Yak Posting Veteran

82 Posts

Posted - 2010-09-27 : 09:37:38
What is the easy way to get the total cost?

I have a field that records a length of time as nVarChar that is formatted hh:mm:ss
I have a money value field that holds the price per minute.

So for example
Time 01:30:30
*
Money £0.60
Total Price = £54.30

Please tell me there is a smplie way to do this?

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2010-09-27 : 11:08:55
declare @date datetime
declare @price money
set @price = $0.60
set @date = '01:30:30'

select datediff(ss,0,@date) * @price /60

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -