Results 1 to 7 of 7
  1. #1
    frustratedwithaccess is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Oct 2014
    Posts
    35

    converting hour into number

    Hello All,



    In one of my access tables, I have a field "time" listing times as hour (i.e. the data entered, contains medium times such as 6:15 AM, 7:16 AM, 9:20 PM etc however I have formatted as "h" to only display the hour). In terms of the new query I need to create, I only need the hour of each time in order to group by hour. However, grouping doesn't work due to initial data being entered with minutes. How can I group specifically by hour in my new query, or how do I convert hour into a number?

    Hope someone can help

    Cheers!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Format property does NOT change the raw data.

    Is this a date/time data type field?

    Use functions to extract date/time parts.

    Year([fieldname])

    Month([fieldname])

    Day([fieldname])

    Hour([fieldname])
    Last edited by June7; 03-04-2015 at 01:54 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    JeffChr is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2014
    Posts
    82
    ... maybe "Format property does not change the raw data." ?

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I have a field "time" listing times
    "Time" is a reserved word in Access (along with "Date", "Month", "Year") and shouldn't be used as object names. "Time" is also a function... Using "Time" as a field name will cause you headaches.
    Plus it is not very descriptive; "Time" of what? Start time, End time, Entry time,...???


    In terms of the new query I need to create,......
    As June said, in a empty column in the query, enter something like
    Code:
    TheHour: Hour([Time])

    -------------------------------------------
    Edit:
    Here is a list of reserved words - http://www.allenbrowne.com/AppIssueBadWord.html

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Quote Originally Posted by JeffChr View Post
    ... maybe "Format property does not change the raw data." ?
    YEP, corrected post. Fingers and brain not coordinating.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    JeffChr is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2014
    Posts
    82
    LOL yep, sometimes mine run at different speeds also.

  7. #7
    frustratedwithaccess is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Oct 2014
    Posts
    35
    Thanks all!

    Managed to get this sorted with suggestion of functions to extract date/time parts.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 07-25-2014, 09:25 AM
  2. Replies: 1
    Last Post: 01-31-2014, 11:03 PM
  3. Replies: 1
    Last Post: 10-20-2013, 10:04 AM
  4. Rounding number up to half hour
    By crxftw in forum Forms
    Replies: 2
    Last Post: 08-23-2011, 07:29 AM
  5. Replies: 2
    Last Post: 03-02-2011, 01:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums