SQL Operations/Functions with TIMESTAMPS

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Billy Bob Smith

    #1

    SQL Operations/Functions with TIMESTAMPS

    I am servicable at writing SQL, but I can't find a whole lot of info
    about what I need to do. I need to write some queries that summarize
    rows in a table based on a TIMESTAMP field.

    We have a table that records accesses to an application in a timestamp
    field. At the simplest level we need to see daily visits. At the
    optimum level we would love to be able to summarize visits by hour.

    Can anyone point me to some functions that will allow me to break the
    timestamp into date/hour components? And if you really want to make me
    happy an example query would rock. :-)

    Thanks in advance.
  • Brian Tkatch

    #2
    Re: SQL Operations/Functions with TIMESTAMPS

    Billy Bob Smith wrote:
    I am servicable at writing SQL, but I can't find a whole lot of info
    about what I need to do. I need to write some queries that summarize
    rows in a table based on a TIMESTAMP field.
    >
    We have a table that records accesses to an application in a timestamp
    field. At the simplest level we need to see daily visits. At the
    optimum level we would love to be able to summarize visits by hour.
    >
    Can anyone point me to some functions that will allow me to break the
    timestamp into date/hour components? And if you really want to make me
    happy an example query would rock. :-)
    >
    Thanks in advance.
    The SQL Reference lists all the FUNCTIONs availble, and can separate
    the DATE field for you. The query you want will probably be GROUP BY,
    and should be a very simple query.

    SELECT YEAR(), MONTH(), DAY(), HOUR(), COUNT(*) FROM GROUP BY YEAR(),
    MONTH(), DAY(), HOUR()

    B.

    Comment

    Working...