CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: sql query

  1. #1
    Join Date
    Jul 1999
    Location
    USA
    Posts
    101

    sql query

    I have timestamp as one of the fields and it's format is '09/29/1999 09:23:23AM'. the timestamp is in 10 minute intervals.

    now, I have to group the data such that timestamp is in hourly interval.

    for ex,

    timestamp count abort
    09/29/1999 08:53:23AM 2121 432

    09/29/1999 09:03:23AM 242 4445

    09/29/1999 09:13:23AM 5353 646
    ....


    should appear as


    timestamp count abort
    09/29/1999 09:00AM 66263 6464

    09/29/1999 10:00AM 103833 493027

    09/29/1999 11:00AM 391015 340202



    and so on...

    so all the data should be grouped(i.e totalled) under hourly interval

    can someone let me know

    thanks












  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: sql query

    OK; this is NOT your solution, but a starter:

    select convert(varchar(14),datum,113), count(*) from wonkaftrg
    group by convert(varchar(14),datum,113)

    it is based on SQLServer, replace "WONKAFTRG" with your table name and "datum" by "timestamp".
    It should give you an idea...



  3. #3
    Join Date
    Jul 1999
    Location
    USA
    Posts
    101

    Re: sql query

    thanks for your response, but what is this 'convert' function?. I get an error message when I am trying to use this. I am using Access database.

    Srikanth


  4. #4
    Join Date
    May 1999
    Posts
    3,332

    Re: sql query

    convert is an SQLServer function for converting any type of value to another type.
    Unfortunately, I don't know how to convert an Access date to a string.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured