Calculated time difference column in create table

  • Hi,

    Can someone please advise on how to include a time difference column using 2 other date columns during creation of a table ?

    The requirement is to create a table and include the following columns:

    1.Downtime start date & time

    2.Downtime end date & time

    3.Downtime Duration in hh:mm (calculated date difference between column 1 and 2)

    Thanks for your time.

  • I would advise you to calculate the time difference in minutes. You can display it as hh:mm in your presentation layer. That said, what is it specifically you don't understand - how to calculate a time difference, how to include a computed column in a table definition, or something else?

    John

  • John Mitchell-245523 (7/14/2015)


    I would advise you to calculate the time difference in minutes. You can display it as hh:mm in your presentation layer. That said, what is it specifically you don't understand - how to calculate a time difference, how to include a computed column in a table definition, or something else?

    John

    Thanks for your reply.

    Actually I need the advise on both - calculating the time difference and including a computed column (hh:mm) in table definition.

    Thanks.

  • OK, for the former, use DATEDIFF. For the latter, look at the CREATE TABLE documentation. Search on that page for "computed_column_expression". Please post back if there's anything you don't understand.

    John

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

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