How to sum a number of rows with minute data where column format is datetime

  • jcelko212 32090

    SSCrazy Eights

    Points: 8758

    You just run into one of the problems with the way time is modeled in Microsoft SQL Server. We talk about time in many different ways. When I'm talking about an hour, I might mean a particular point in time within the cycle of a day (the train arrives at 13:00 hours). I could also mean an interval of time/ duration not connected to another unit of measurement (the train takes three hours to get there). This is why the full ANSI/ISO standards have interval data types and their temporal model.

    To go from the timestamp/point in time data you have in SQL server, you're going to have to use some temporal math to turn them into durations before you can add them. These are two very different kinds of scales. Then when you use the temporal difference functions in SQL server, you have to decide what degree precision you want (rounding it two hours, minutes or seconds).

    Please post DDL and follow ANSI/ISO standards when asking for help. 

Viewing post 16 (of 16 total)

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