How to calculate up to Millisecond

Post Reply
Firefly007
Posts: 19
Joined: Tue Feb 26, 2013 12:51 am
OLAP Product: TM1 10.1.1
Version: Tm1 9.0
Excel Version: excel 2007

How to calculate up to Millisecond

Post by Firefly007 » Sat Apr 06, 2013 1:57 am

I was able to get value only up to seconds . can we calculate up to Milliseconds ?
V1= Now;
V2=TIMST(V1, ' \H\p \imin\ssec');

tomok
MVP
Posts: 2529
Joined: Tue Feb 16, 2010 2:39 pm
OLAP Product: TM1, Palo
Version: Beginning of time thru 10.2
Excel Version: 2003-2007-2010-2013
Location: Atlanta, GA
Contact:

Re: How to calculate up to Millisecond

Post by tomok » Sat Apr 06, 2013 2:22 am

What does the documentation say?
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/

Firefly007
Posts: 19
Joined: Tue Feb 26, 2013 12:51 am
OLAP Product: TM1 10.1.1
Version: Tm1 9.0
Excel Version: excel 2007

Re: How to calculate up to Millisecond

Post by Firefly007 » Sun Apr 07, 2013 9:21 pm

In the documentation I could not find calculation upto Milliseconds. The least i was able to find only upto seconds.

User avatar
Alan Kirk
Site Admin
Posts: 5878
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2 Classic (PAW-free zone)
Excel Version: 2010 and 2016
Location: Sydney, Australia
Contact:

Re: How to calculate up to Millisecond

Post by Alan Kirk » Sun Apr 07, 2013 9:28 pm

Firefly007 wrote:In the documentation I could not find calculation upto Milliseconds. The least i was able to find only upto seconds.
Are you really talking about calculating to milliseconds, or displaying milliseconds?

What, in short, is your intent?

The TM1 system does go down to millisecond level as you can see from some of the performance manager cubes; whether you can rely on the accuracy of that is another matter.

Have you read this post on dates and times? If so, you should be aware that milliseconds are merely represented by decimal places way out to the right.

There is not (as far as I'm aware) a TM1 formatting code for converting them into a string showing milliseconds but it should be easy enough to work out how to do so when you understand how the values are stored. But again it depends on whether your intention is calculation or display.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.

Firefly007
Posts: 19
Joined: Tue Feb 26, 2013 12:51 am
OLAP Product: TM1 10.1.1
Version: Tm1 9.0
Excel Version: excel 2007

Re: How to calculate up to Millisecond

Post by Firefly007 » Sun Apr 07, 2013 9:46 pm

I went through the link which you have provided. I still cannot figure out how to display upto milliseconds. I am trying to append the timestamp to an ascii output file.

This one displays only upto seconds as given in document.
V2=TIMST(V1, ' \H\p \imin\ssec');

User avatar
Alan Kirk
Site Admin
Posts: 5878
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2 Classic (PAW-free zone)
Excel Version: 2010 and 2016
Location: Sydney, Australia
Contact:

Re: How to calculate up to Millisecond

Post by Alan Kirk » Sun Apr 07, 2013 11:02 pm

Firefly007 wrote:I went through the link which you have provided. I still cannot figure out how to display upto milliseconds. I am trying to append the timestamp to an ascii output file.

This one displays only upto seconds as given in document.
V2=TIMST(V1, ' \H\p \imin\ssec');
That does quite surprise me given that I had already said:
I wrote:There is not (as far as I'm aware) a TM1 formatting code for converting them into a string showing milliseconds
and then went on to add:
I wrote:but it should be easy enough to work out how to do so when you understand how the values are stored.
I'm sure that you took the time to carefully read the article that I referred you to, but it's possible that you missed one of the key points so allow me to elaborate.

A day is represented by the value 1. This is 24 hours, or 1,440 minutes, or 86,400 seconds, or 86,400,000 milliseconds.

If you were to take the decimal component of the value returned by Now() (that is, as the article explains, the time component of the value), you would have the decimal fraction of the day that has elapsed so far. This value can be manipulated in various ways.

1/24 represents the number of hours in a day, yes? So you could divide the decimal component of Now() by (1/24), then take the integer of that to get the number of completed hours so far in the day.

If you want to get the number of completed minutes since the start of the day instead, replace (1/24) with (1/1440).

If you want the number of completed minutes in the current hour, take the number of completed minutes, and subtract (the number of completed hours * 60).

Are you seeing the pattern?

It is possible that someone has already written the necessary code to extract the number of milliseconds, and that they will eventually post it which you can then use without any effort.

But in the absence of that, if you follow the calculation methods above you will be able to calculate down to the number of milliseconds for yourself, then just convert that value to a string.

Incidentally, if you are writing so many log files that they need to be separated down to the millisecond... you may well be adversely affecting TM1's performance. Writing to disk is (relatively) slow (certainly compared to in memory operations) and therefore something to be done sparingly. If you're doing it so often that a timestamp down to the second isn't sufficient, it may be worth rethinking what you're doing and why.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.

rmackenzie
MVP
Posts: 733
Joined: Wed May 14, 2008 11:06 pm

Re: How to calculate up to Millisecond

Post by rmackenzie » Mon Apr 08, 2013 12:02 am

Firefly007 wrote:I was able to get value only up to seconds . can we calculate up to Milliseconds ?
V1= Now;
V2=TIMST(V1, ' \H\p \imin\ssec');
It's also worth bearing in mind this nugget of information that Duncan posted about:
Duncan P wrote:Although NOW may return a number that looks very precise the granularity is in fact one second.
So although you may be able to get the current time at the precision of milliseconds, it may be a piece of information that you are not able to really use in a meaningful way. What are you trying to do with the timestamp?
Robin Mackenzie

User avatar
Alan Kirk
Site Admin
Posts: 5878
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2 Classic (PAW-free zone)
Excel Version: 2010 and 2016
Location: Sydney, Australia
Contact:

Re: How to calculate up to Millisecond

Post by Alan Kirk » Mon Apr 08, 2013 12:32 am

rmackenzie wrote:
Firefly007 wrote:I was able to get value only up to seconds . can we calculate up to Milliseconds ?
V1= Now;
V2=TIMST(V1, ' \H\p \imin\ssec');
It's also worth bearing in mind this nugget of information that Duncan posted about:
Duncan P wrote:Although NOW may return a number that looks very precise the granularity is in fact one second.
So although you may be able to get the current time at the precision of milliseconds, it may be a piece of information that you are not able to really use in a meaningful way.
Interesting; Duncan appears to be correct (not that I'd doubt it). But out of curiosity I ran some similar tests. The value returned certainly has the precision (1/86,400,000 of a day (1 millisecond) has its first significant digit at the 8th decimal place, and the Now() function returns far more than that), but the problem is the accuracy. (As I'd referred to in my first reply, but I didn't realise that it was as bad as this.) The value returned doesn't seem to be updated / read from the system clock in real time but only periodically; as Duncan observed, most likely each second or so. As a result you can be banging away retrieving timestamps constantly and get the same value for most of any given second.
rmackenzie wrote:What are you trying to do with the timestamp?
That was mentioned in their last reply:
Firefly007 wrote:I am trying to append the timestamp to an ascii output file.
As I said in my last one, if you need AsciiOutput timestamps down to the millisecond... the process that calls for that may be worth reviewing.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.

Firefly007
Posts: 19
Joined: Tue Feb 26, 2013 12:51 am
OLAP Product: TM1 10.1.1
Version: Tm1 9.0
Excel Version: excel 2007

Re: How to calculate up to Millisecond

Post by Firefly007 » Thu May 02, 2013 9:25 pm

Sorry for responding late.

The purpose for this milliseconds was to check for flags files to save data to disk depending on the time stamp.I had four process which run in parallel.i was using test data which caused four process to complete almost same seconds so i was trying go up to milliseconds. how ever it was not the scenarios when i went with complete data set . for now I am good up to seconds. Thank for your help.

Post Reply