Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2010
    Posts
    2

    Unanswered: how to calculate time part

    I HAVE STRING COLUMN SAY "TIME_USED" WITH 'HOURS:MINSECONDS' (eg 153:29:41) FORMAT

    I NEED TO CALCULATE IT TYPICALLY AND STORE IT IN SOME OTHER VARIABLE PLEASE CHECK;

    --> (MINS.SECONDS)/60 ie (29.41)/60=0.4901
    and concatinate this value to HOURS ie 153.4901


    how to do this, i cant use like operator and get the data and do in one go for sql, can any one help me out

    Regards
    Naren

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    As ever, this sort of thing would have been much easier if the designer had not tried to be clever and simply had a start date\time and an end date\time column.

    Can you see how to get it from this?
    Code:
    SELECT
            the_seconds     = PARSENAME(REPLACE('153:29:41', ':', '.'), 1)
          , the_minutes     = PARSENAME(REPLACE('153:29:41', ':', '.'), 2)
          , the_hours       = PARSENAME(REPLACE('153:29:41', ':', '.'), 3)
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Jan 2010
    Posts
    2

    Thumbs up

    Thanks a lot..

Posting Permissions

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