Records per hour?

  • Hi all

    I can't find an elegant solution for this seemingly simple problem.

    I have a table (Job) with a field that includes a timestamp.

    I need to draw a report for the number of records in table Job per day / hour / minute for the day / week month.

    Something like this:

    DateJobCount

  • Does your table have another field that is actually related to the date of the records? Despite its' name, a timestamp field has nothing to do with time and cannot be used for this kind of query.

    If you do have another date field, please post the table definition for us and you're right, it is a very simple query. If you do not have another date field, you're hosed. Timestamps cannot be used for chronological sorting.

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • BOL[


    timestamp

    timestamp is a data type that exposes automatically generated binary numbers, which are guaranteed to be unique within a database. timestamp is used typically as a mechanism for version-stamping table rows. The storage size is 8 bytes.

    Remarks

    The Transact-SQL timestamp data type is not the same as the timestamp data type defined in the SQL-92 standard. The SQL-92 timestamp data type is equivalent to the Transact-SQL datetime data type.

    A future release of Microsoft® SQL Server™ may modify the behavior of the Transact-SQL timestamp data type to align it with the behavior defined in the standard. At that time, the current timestamp data type will be replaced with a rowversion data type.

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

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

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