getting the hour

Results 1 to 3 of 3

Thread: getting the hour

  1. #1
    pj Guest

    Default getting the hour

    My boss wants me to break down some data into hourly activity instead of just daily activity, but I am having trouble extracting the hour. I haven&#039t found in my SQL book how to do this. In my SQL statement I am trying to get just the hour from a timestamp. I am saying "SELECT hour(myDateField) AS theHour FROM myTable". It doesn&#039t recognize my attempt to use an &#039hour&#039 function. Do you know how I can get just the hour (1-24)?<BR>Thanks for any help!

  2. #2
    sm549 Guest

    Default RE: getting the hour

    It depends on the database. What database are you using? <BR>Hour() should work for access, assuming the field contains a valid datetime. For SQL Server try selecting datepart(hh, myDateField).

  3. #3
    pj Guest

    Default RE: getting the hour

    Hey, that worked great with SQL Server. Thanks!

Posting Permissions

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