[thelist] Understanding an SQL Problem

rudy r937 at interlog.com
Tue Jan 7 18:27:31 CST 2003


> Now I just need to automate the hour accessed...

select hour(TimeAccessed), count(*)
  from IntranetLog
 where DateAccessed = '2003-01-06'
group by hour(TimeAccessed)


i wonder if this would be a good time (no pun intended) to mention that you
do not need two fields for date and time

an sql server datetime field carries both a date and a time component, so
you should really just use one to carry both, when, as in this example, the
date and time portions belong to the same event

<tip type="sql">
when specifying date literals, always use ISO format, so that you never
accidentally enter march 4th when you meant to enter april 3rd
</tip>

rudy




More information about the thelist mailing list