+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 16 to 27 of 27

Format(Time(), "h:mm") gives wrong format

  1. #16
    Registered User
    Join Date
    11-14-2019
    Location
    Finland
    MS-Off Ver
    2016
    Posts
    32

    Re: Format(Time(), "h:mm") gives wrong format

    Quote Originally Posted by Roel Jongman View Post
    Ah ok.. this is one of the few times you need semicolon as separator I think

    try this
    Please Login or Register  to view this content.
    You were correct, it now shows only the time.
    Bad news is, the time is still in format h.mm :D

    Personally I would be doubting if I'm sure about nothing else affecting the result at this point. So just to assure you, I tried changing the whole thing to
    Please Login or Register  to view this content.
    and indeed, "debug" I got

  2. #17
    Forum Guru Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,224

    Re: Format(Time(), "h:mm") gives wrong format

    You could use:
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #18
    Registered User
    Join Date
    11-14-2019
    Location
    Finland
    MS-Off Ver
    2016
    Posts
    32

    Re: Format(Time(), "h:mm") gives wrong format

    Quote Originally Posted by Olly View Post
    You could use:
    Please Login or Register  to view this content.
    I don't understand why I didn't think of that.
    I'll have to give it a go tomorrow, but if even that will fail, then I don't trust anything anymore.
    Thanks!

  4. #19
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003, 2007, 2010 & 2013
    Posts
    18,924

    Re: Format(Time(), "h:mm") gives wrong format

    or perhaps
    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  5. #20
    Registered User
    Join Date
    11-14-2019
    Location
    Finland
    MS-Off Ver
    2016
    Posts
    32

    Re: Format(Time(), "h:mm") gives wrong format

    Quote Originally Posted by Olly View Post
    You could use:
    Please Login or Register  to view this content.
    I haven't tested this yet but I realized that since a lot of code is based in these time values, this would probably complicate using this value a lot?
    For example calculating total hours from values like this would have to be much more complicated formula, and others like it

  6. #21
    Registered User
    Join Date
    11-14-2019
    Location
    Finland
    MS-Off Ver
    2016
    Posts
    32

    Re: Format(Time(), "h:mm") gives wrong format

    I get a lot of good ideas, out of which none that I have tried have worked yet.
    Does anyone understand WHY this happens?

  7. #22
    Forum Contributor
    Join Date
    12-22-2017
    Location
    INDIA
    MS-Off Ver
    EXCEL 2007
    Posts
    104

    Re: Format(Time(), "h:mm") gives wrong format

    Use this time format

    Private Sub CommandButton1_Click()
    UserForm1.TextBox1.Value = Format(Time, "hh:mm")
    End Sub
    If solved press * add reputation

  8. #23
    Forum Guru Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,224

    Re: Format(Time(), "h:mm") gives wrong format

    Quote Originally Posted by Jupsu View Post
    For example calculating total hours from values like this would have to be much more complicated formula, and others like it
    Your purpose is not clear. You're trying to store a time value as a string in a textbox, then you want to perform time calculations on this value? Using TIMEVALUE on the textbox value (formatted per my suggestion) should work:

    Please Login or Register  to view this content.

  9. #24
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    4,426

    Lightbulb

    Hi,

    or from a string data you can use the VBA CDate function

  10. #25
    Registered User
    Join Date
    11-14-2019
    Location
    Finland
    MS-Off Ver
    2016
    Posts
    32

    Re: Format(Time(), "h:mm") gives wrong format

    Quote Originally Posted by Andy Pope View Post
    or perhaps
    Please Login or Register  to view this content.
    this didn't work either

  11. #26
    Registered User
    Join Date
    11-14-2019
    Location
    Finland
    MS-Off Ver
    2016
    Posts
    32

    Re: Format(Time(), "h:mm") gives wrong format

    Quote Originally Posted by chandy123987 View Post
    Use this time format

    Private Sub CommandButton1_Click()
    UserForm1.TextBox1.Value = Format(Time, "hh:mm")
    End Sub
    tried it earlier, no change

  12. #27
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003, 2007, 2010 & 2013
    Posts
    18,924

    Re: Format(Time(), "h:mm") gives wrong format

    If the time is give you a decimal point rather than colon then how about a simple text replace?

    Please Login or Register  to view this content.

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1