Hi, We are using an application .It 's database is on SQL server 2000. One of its module is getting the information from pbx and writing the cost to customer's folios.But sometimes it cannot calculate the right cost because of signalization.Database has a table with column writing the time in mm:ss format.I want to write a trigger that will calculate and insert the right cost if it is wrong.But i have to change the time format from mm:ss to seconds only,for calculating .How can i do it.(It must convert to seconds only while calculating but it musn't change the format on the table else program won't run properly)Thanxis the column a datetime datatype or is the data stored as mm:ss in, I guess a varchar datatype?
if you have a datetime datatype then use DATEPART to extract the minutes and seconds and do the math.
select (DATEPART(mi,<column>) * 60) + DATEPART(ss,<column>)
if you have a varchar datatype then you follow the same idea but convert the strings into ints.
select cast(left(<column>,2) as int) * 60) + cast(right(<column>,2) as int)
No comments:
Post a Comment