how to calculate Time Diff

  • hello,

    I have used below conversion for date-time to find time from date.

    LTRIM(RIGHT(Convert(VARCHAR(20), PGL.[In-Time],100),7))as In_Time,

    LTRIM(RIGHT(Convert(VARCHAR(20), PGL.[Out-Time],100),7)) as Out_Time

    Now I have to calculate time difference? How can I do it?

    please suggest...

    Reply awaited..

  • You can use DATEDIFF for time as well as dates. No need for the conversion - just DATEDIFF(second/minute/hour, In-Time, Out-Time)

    https://msdn.microsoft.com/en-us/library/ms189794.aspx

  • what i understand from your question is that you are looking for the Time portion from the datetime field.

    DateTime: 24-Jun-2015 12:45:35.000

    and your are looking for

    '12:45:35.000' only.

    check the following link

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply