Options

Time in HH:MM:SS format

sunnyksunnyk Member Posts: 276
Greetings,
How can we convert TIME into HH:MM:SS format. I mean if the Time is 5:45:23 AM then it should come as 05:45:23 and if the TIME is 5:45:23 PM then it should come as 17:45:23. Using DELCHAR i am able to delete AM and PM from TIME but how to add extra 0 if any of the hour/min/seconds are in Single Digit. We can have DATE2DMY to get Year, Month and Day from the Date. But, How can we do this for the TIME.

Comments

  • Options
    sunnyksunnyk Member Posts: 276
    Any Suggestions?
  • Options
    reijermolenaarreijermolenaar Member Posts: 256
    Are you able to get the time in a variable of type Time?

    I read that you were able to remove the AM/PM part so you can do a evaluate with the other part link this:
    EVALUATE(Time2, '5:45:23');

    Then you can use the following format command:
    FORMAT(Time2, 0, '<Hours24,2><Filler Character,0>:<Minutes,2>:<Seconds,2>');
    Reijer Molenaar
    Object Manager
  • Options
    garakgarak Member Posts: 3,263
    Take a look to the FORMAT function.

    Go to C/AL Symbol Menuy -> System -> Variables -> Format -> press then F1 and read there also the HELP behind the Hyperlink (FORMAT property).

    There u will find examples like this:

    Time / Format / Example
    <Hours24>.<Minutes,2>.<Seconds,2> / 0 / 4.35.55
    <Hours24>.<Minutes,2>.<Seconds,2><Second dec.> / 1 / 4.35.55.553
    Do you make it right, it works too!
  • Options
    sunnyksunnyk Member Posts: 276
    Thanks Rene, This is exactly what i want. =D>
  • Options
    David_SingletonDavid_Singleton Member Posts: 5,479
    Is it really faster to post a question than to Press F1? :whistle:
    David Singleton
  • Options
    garakgarak Member Posts: 3,263
    Please and welcome.

    And don't forgett (and don't missunderstood me)
    .
    1. Use the brain ;-)
    2. use the help (step 1 must also be run :-) ) <- it's very powerfull
    3. search the forum <- if you doesn't found anything in the help
    4. create a question, if 1,2 and 3 doesn't bring you to your goal ;-)

    Regards
    Do you make it right, it works too!
  • Options
    SRishiSRishi Member Posts: 26
    Use the Evaluate Function it will simply convert the date or time to specific date or time format
    Ex. :- EVALUATE(RealDate,'19022018'); // For Any Date which you want to convert (19-Feb-2018)
    EVALUATE(RealTime,'142930'); // For Any Date which you want to convert (14:29:30)
Sign In or Register to comment.