Planning Analytics

Planning Analytics

Get AI-infused integrated business planning

 View Only

Printing the date of today and time of now

  • 1.  Printing the date of today and time of now

    Posted Sun May 11, 2025 07:22 PM
    Edited by Wim Gielis Sun May 11, 2025 07:24 PM

    Hello all,

    Here is some code related to dates and times:

    DatasourceASCIIQuoteCharacter = '';
    
    n = Now;
    
    sNow = Timst( n, '\d-\m-\Y \h:\i:\s' );
    ASCIIOutput( 'test.txt', sNow );
    
    i = NewDateFormatter( 'nl_BE', 'Europe/Brussels', '', '', 'datetime' );
    v = FormatDate( n, 'EEEE dd MMMM y - H:mm', i );
    ASCIIOutput( 'test.txt', v );
    
    i = NewDateFormatter( 'nl_BE', 'Europe/Brussels', '', '', 'date' );
    v = FormatDate( Dayno( Today(0)), 'EEEE dd MMMM y', i );
    ASCIIOutput( 'test.txt', v );

    I am now Monday morning 0:30, May 12, 2025 in Belgium (I chose this timing to make the difference with UTC time as we are now UTC/GMT +2 hours).

    Executed in IBM PAoC (probably a data center in Germany and same timezone):
    11-05-2025 22:30:32
    Monday 12 May 2025 - 0:30
    Sunday 11 May 2025

    Executed on my own laptop TM1 2.0.9.21 - Belgian settings:
    12-05-2025 00:30:51
    Monday 12 May 2025 - 2:30
    Monday 12 May 2025

    Findings:
    - LINE 1: Now() gives a time in UTC, or so I thought (viewtopic.php?p=47871#p47871). Why would the result then change depending on where the code is executed ? Now does not seem to return UTC.
    - LINE 2: Why the difference if I specifically mention that the timezone is Europe/Brussels ? PAoC seems to be correct.
    - LINE 3: Also a difference ? Laptop seems to be correct.

    The ultimate goal is to just print the date and time of "now" in a cube for a given timezone. That seems to be harder than I thought unless I am missing something.
    And code that is universal irrespective of server locations or PA versions/delivery methods.
    Or should I take into account server locations in any of these calculations, like Yuri wrote about (https://www.ykud.com/blog/pa_timezone) ?

    Cross-posted at TM1forum for a wider audience: https://www.tm1forum.com/viewtopic.php?t=16854



    ------------------------------
    Wim Gielis
    Senior Consultant
    Aexis International
    Sint-Stevens-Woluwe
    +32496225001
    ------------------------------