samedi 9 mai 2015

How to manipulate a returned datetime value in T-SQL

I need to determine the average amount of time it takes our fulfillment team to process orders.

I plan to simply count the number of "seconds" between the "PaidDateUtc" and "ShippedDateUtc" value for each order, and then get the average.

My simplified query (minus the date range filter) is like this:

SELECT
    dbo.Shipment.ShippedDateUtc - dbo.[Order].PaidDateUtc AS TimeToFulfill
FROM
    dbo.[Order] INNER JOIN
    dbo.Shipment ON dbo.[Order].Id = dbo.Shipment.OrderId

The returned value looks like this:

1900-01-01 00:25:27.263

Which means: 1 day, 1 hour, 25 minutes, and 27 seconds

My question is: How can I manipulate it so that the returned value looks like this:

91527     --(total of seconds)

Aucun commentaire:

Enregistrer un commentaire