Thread: changing the time format
06-15-02, 06:19 #1Registered User
- Join Date
- Jun 2002
Unanswered: changing the time format
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)Thanx
06-18-02, 10:50 #2Registered User
- Join Date
- Feb 2002
- Houston, TX
is 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)Paul Young
(Knowledge is power! Get some!)