Results 1 to 8 of 8
  1. #1
    smc678 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    65

    Time/Number formating

    How in a query can I turn a 32:15 hour to a 32.25 number

  2. #2
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    What is the underlying data stored as? 32:15 is more than a day, so it normally wouldn't look that way.

    However, assuming that it is a standard MS date/time field, stored in hours, without the year/month/day part, then multiply by 24 to get a decimal number of hours. the reason is because a Date/time field stores dates and +1 is one day (24 hours) later.

    You might need to force/cast the type with Round( (your expression) , 2) or CDec(Your expression) or some similar method.

  3. #3
    smc678 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    65
    32:15 is 33 hours and 15 min. This comes from a table whick is updated by kronos and is a text field in the table.

  4. #4
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Okay.

    It's not elegant, but try this:
    Code:
    IIF(instr(,Mytime,":")>0,round(int(left(MyTime,instr(Mytime,":")-1)) + (100*int(mid(MyTime,instr(Mytime,":")+1,2))/60),2),0)

  5. #5
    smc678 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    65
    So a number returned but it added 32:15 came out 57 and 37:30 came out 87?

  6. #6
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Okay, remove the 100*

    I was first trying to build the string then switched to creating the number; forgot to remove the multiplier.

  7. #7
    smc678 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    65
    It says its an invalid syntex dur to commas? IIF(instr(,[Total Hours],":")>0,round(int(left([Total Hours],instr([Total Hours],":")-1)) + (int(mid([Total Hours],instr([Total Hours],":")+1,2))/60),2),0)

  8. #8
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    remove the comma after the open paren in "IIF(instr(,[Total"

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

Similar Threads

  1. Counting number of instances by time of day
    By Abarency in forum Queries
    Replies: 1
    Last Post: 11-11-2012, 04:53 PM
  2. Convert Number to Date/Time
    By Jerseynjphillypa in forum Queries
    Replies: 10
    Last Post: 06-13-2012, 12:33 PM
  3. Unbound Phone Number Not Formating
    By Huddle in forum Access
    Replies: 3
    Last Post: 02-13-2012, 05:10 PM
  4. Dividing time by a specific number
    By harrig04 in forum Queries
    Replies: 1
    Last Post: 07-05-2011, 09:09 AM
  5. date/time number
    By playfuljade in forum Forms
    Replies: 4
    Last Post: 12-19-2005, 12:52 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