• jwiseh (1/31/2015)


    I remember the pain of working with a system where a developer had chosen the TIME data type to store the number of hours worked in a day. Anyone want to figure out how you add two TIME columns together? I'll wait…

    Okay, at risk of noob humiliation, why not store these as a TIME data type? Doesn't seem too difficult to calculate to me:

    [font="Courier New"]-- Set up a couple times to work with...

    DECLARE @Start AS TIME = '08:05:00 AM', @End AS TIME = '01:22:00 PM';

    -- Find the number of hours worked (CASTing DATEDIFF int output data type)...

    SELECT CAST(DATEDIFF(MINUTE,@Start,@End) AS NUMERIC)/60 AS 'HoursWorked';[/font]

    What's more, you'd want to convert this to a numeric format for future calculations, such as HoursWorked * PayRate = PaycheckAmount

    Perhaps I'm not understanding the way you worded your statement correctly?

    Guess this would be fine for a very short lived organism which goes into retirement around 24h of age;-)

    😎