NewDateFormatter

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:

NewDateFormatter

Post by Wim Gielis »

Hi all

I found 3 interesting new functions in the Reference Guide 10.2: NewDateFormatter, FormatDate, ParseDate.

Useful stuff!
However, I get wrong results, it seems, or I am interpreting the results the wrong way.

In the Prolog tab, since I'm based in Brussels (Belgium):

Code: Select all

i = NewDateFormatter('nl_BE', 'Europe/Brussels', 'serial', 'long', 'datetime');
now_formatted = FormatDate( now, 'HH:mm:ss' );
AsciiOutput('test.txt', now_formatted);
The result is 18:48 for me currently in Belgium it is 16:48 (4:48 PM).

Hence, 2 hours of difference.

if I use:

Code: Select all

i = NewDateFormatter('nl_BE', 'Etc/UTC', 'serial', 'long', 'datetime');
I get the correct result but this is not how the function should be used, is it?

See http://en.wikipedia.org/wiki/List_of_tz ... time_zones for time zones.

Did anyone use the function?

Wim
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
dr.nybble
MVP
Posts: 160
Joined: Wed Aug 17, 2011 3:51 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: Excel 2007

Re: NewDateFormatter

Post by dr.nybble »

The TM1 function NOW returns a value that is interpreted as UTC time.
So you need to pass 'Etc/UTC' as the timezone when formatting it.

Passing a different timezone would be useful if, for example, you were parsing timestamps that were not UTC but a local time.
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: NewDateFormatter

Post by Wim Gielis »

Thank you for the reply, that makes sense.
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