Printing the date of today and time of now

Post Reply
Wim Gielis
MVP
Posts: 3229
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.1.5
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Printing the date of today and time of now

Post by Wim Gielis »

Hello all,

Here is some code related to dates and times:

Code: Select all

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) ?
Best regards,

Wim Gielis

IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Wim Gielis
MVP
Posts: 3229
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.1.5
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: Printing the date of today and time of now

Post by Wim Gielis »

Cross-posted here for a wider audience:

https://community.ibm.com/community/use ... 4eda43146b
Best regards,

Wim Gielis

IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Post Reply