Results 1 to 6 of 6
  1. #1
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    340

    Working with mins and secs

    Just trying to get my head around this..


    I have a time in string format as "2.40" and want to add this to a Date Field formatted "mm:ss". (If that's right - should "ss" be "n")
    Code:
    Function Dur(f as string) As Date
       'f= "2.40"
        Dur = "00." & Minute("00." & f) & "." & Second("00." & f)
    End Function
    When i print the result I see 12:02:40 AM which is not really what's wanted.
    If I put 12:02:40 AM into my date field will it lose the 12 and AM ?
    I will try and see. Or and I doing this all wrong and a better way exists?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Does 2.40 really represent 2 minutes and 40 seconds or is that 4/10 of minute which is 24 seconds?

    Use "nn" for minutes - "mm" is for month.
    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
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    340
    Thanks June. 2.40 is 2 min and 60sec. I found "nn:ss" was correct format for the field
    Is it correct you cannot have Min and Secs without an hour, and you cannot lose the leading 0 from e.g. 02.40 ?
    I also found the 3rd line in my example wasn't needed, just send in "0.2.40". Is that the right way to do it ?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Wait, 2.40 cannot be 2 min and 60 sec. Usually, a period is representing a decimal point and that means a fraction and semicolon is used as separator for h:m:s.

    If you don't want placeholder 0: Dur = "0." & Minute("0." & f) & "." & Second("00." & f)
    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.

  5. #5
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    340
    I ended updating the table with just = "0." & Split(theDat, " ")(0) - becoming 0.2.40
    That became 12:02:40 AM with the value displayed in the table 02:40.
    Changed to = "0." & Minute("0." & f) & "." & Second("00." & f) but that still showed a leading 0.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    It did not have leading 0 in my quick test.

    Glad you have a solution.
    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.

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

Similar Threads

  1. Replies: 2
    Last Post: 05-14-2017, 10:07 AM
  2. Replies: 2
    Last Post: 02-23-2016, 11:29 AM
  3. Working query stops working after importing
    By Abacus1234 in forum Import/Export Data
    Replies: 3
    Last Post: 10-25-2015, 09:12 PM
  4. Elapsed time hrs mins secs
    By dasousa in forum Programming
    Replies: 20
    Last Post: 05-17-2015, 08:39 AM
  5. Replies: 3
    Last Post: 01-29-2013, 04:34 AM

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