Results 1 to 2 of 2
  1. #1
    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

  2. #2
    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!)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts