Increasing Time by 8 hours
-
- Posts: 141
- Joined: Wed Mar 09, 2011 1:25 pm
- OLAP Product: TM1
- Version: 10.2.2
- Excel Version: 2003 2007 2010 2013
Increasing Time by 8 hours
Hi all
Ive read all there is on the TIME and date piece Written by Alan, but im still struggling to find what i need.
My server is 8 hours behind due to the location of the server and the timezone it sits in.
I have created a TI that collects data from a monitoring cube and trying to get it in to another cube at GMT time,
I need the Date and the hour the problem i have is if i simply subst TIME and add 8 then it works fine until it goes past the Day.
i.e
server time is 17:00
Date on server is 28/07/13
if i add 8 to the time
New Time 01:00
Date on server is 28/07/13
I understand i can write a complex if system, to get it correct, but I was wondering if there was a quicker alternative rather than using IFs
thanks
Ive read all there is on the TIME and date piece Written by Alan, but im still struggling to find what i need.
My server is 8 hours behind due to the location of the server and the timezone it sits in.
I have created a TI that collects data from a monitoring cube and trying to get it in to another cube at GMT time,
I need the Date and the hour the problem i have is if i simply subst TIME and add 8 then it works fine until it goes past the Day.
i.e
server time is 17:00
Date on server is 28/07/13
if i add 8 to the time
New Time 01:00
Date on server is 28/07/13
I understand i can write a complex if system, to get it correct, but I was wondering if there was a quicker alternative rather than using IFs
thanks
-
- Community Contributor
- Posts: 103
- Joined: Mon Sep 05, 2011 11:04 pm
- OLAP Product: TM1
- Version: 10.2
- Excel Version: 2010
Re: Increasing Time by 8 hours
Can you just convert everything to a serial time and use that to add the 8 hours. Just add 1/3 to the serial time.
-
- Posts: 141
- Joined: Wed Mar 09, 2011 1:25 pm
- OLAP Product: TM1
- Version: 10.2.2
- Excel Version: 2003 2007 2010 2013
Re: Increasing Time by 8 hours
Only just starting to play with the "Time Features" (never had a need to till now) I dont fully understand the add 1/3 sorry can you explain a little more?
I wrote this based on Alan Kirks writeup
does anyone have any pointers because this does not work when converting it back..
s_TimeStamp1 = TimSt (Now, '\Y\m\d\h\i\s');
s_TimeStamp2 =Stringtonumber(s_TimeStamp1 );
s_TimeStamp3= 8;
s_TimeStamp4= s_TimeStamp2+ s_TimeStamp3;
s_TimeStamp5 = numbertostring(s_TimeStamp4);
s_TimeStamp6= TimSt (s_TimeStamp4, '\Y \M \d \h \i \s');
asciioutput(exportfile1,s_TimeStamp1,s_TimeStamp6);
I wrote this based on Alan Kirks writeup
does anyone have any pointers because this does not work when converting it back..
s_TimeStamp1 = TimSt (Now, '\Y\m\d\h\i\s');
s_TimeStamp2 =Stringtonumber(s_TimeStamp1 );
s_TimeStamp3= 8;
s_TimeStamp4= s_TimeStamp2+ s_TimeStamp3;
s_TimeStamp5 = numbertostring(s_TimeStamp4);
s_TimeStamp6= TimSt (s_TimeStamp4, '\Y \M \d \h \i \s');
asciioutput(exportfile1,s_TimeStamp1,s_TimeStamp6);
-
- MVP
- Posts: 3241
- 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: Increasing Time by 8 hours
As 1 day (24 hours) stands for a value of 1, 8 hours will be equal to 1/3.Darkhorse wrote:Only just starting to play with the "Time Features" (never had a need to till now) I dont fully understand the add 1/3 sorry can you explain a little more?
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
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
-
- Posts: 141
- Joined: Wed Mar 09, 2011 1:25 pm
- OLAP Product: TM1
- Version: 10.2.2
- Excel Version: 2003 2007 2010 2013
Re: Increasing Time by 8 hours
Wim can i be a little cheeky and ask for an example of how to write that?
-
- MVP
- Posts: 3241
- 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: Increasing Time by 8 hours
Come on, you must be kidding.Darkhorse wrote:Wim can i be a little cheeky and ask for an example of how to write that?
For example, the Now function gives you a serial number.
Adding 8 hours to that just means that you need to do:
+1/3
It's as simple as that.
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
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
-
- Posts: 23
- Joined: Fri Jun 21, 2013 5:10 pm
- OLAP Product: TM1
- Version: 9.5.2
- Excel Version: 2010
Re: Increasing Time by 8 hours
Hey guys, first time posting on TM1Forum, you guys have been an invaluable source of information during my TM1 training days.Darkhorse wrote:Wim can i be a little cheeky and ask for an example of how to write that?
Darkhorse, it looks like you're trying to add 8 directly to the serial date number. In the serial date, hours and minutes are fractions of 1, so 6 hours would be 0.25 or 6/24 and 8 hours would be 1/3 or 8/24. I would suggest this method for reaching the serial date you desire.
Code: Select all
nSerialDateNow = NOW;
nSerialDate8HoursFromNow = nSerialDateNow + (8/24);
s_TimeStamp1 = TimSt (nSerialDateNow, '\Y\m\d\h\i\s');
s_TimeStamp2 = TimSt (nSerialDate8HoursFromNow, '\Y\m\d\h\i\s');
Cheers,
Brian
-
- Site Admin
- Posts: 6667
- Joined: Sun May 11, 2008 2:30 am
- OLAP Product: TM1
- Version: PA2.0.9.18 Classic NO PAW!
- Excel Version: 2013 and Office 365
- Location: Sydney, Australia
- Contact:
Re: Increasing Time by 8 hours
Loosely based, I think, because...Darkhorse wrote:Only just starting to play with the "Time Features" (never had a need to till now) I dont fully understand the add 1/3 sorry can you explain a little more?
I wrote this based on Alan Kirks writeup
Nowhere in the article do I suggest that the above would work, nor do I even mention the StringToNumber function. And this is for a very good reason; StringToNumber is not a "smart" function. It's not designed to look at a string, think "Oh, that looks like a date and time, I'll convert it to a serial date". All it does is take any numeric characters or digit group or decimal separators (such as commas and decimal points, respectively) and try to convert them into a corresponding number. StringToNumber will never see the string "2013" as the 2013th year of the common calendar. It only sees it as the characters "2", "0", "1" and "3" to be converted into the number 2013.Darkhorse wrote:does anyone have any pointers because this does not work when converting it back..
s_TimeStamp1 = TimSt (Now, '\Y\m\d\h\i\s');
s_TimeStamp2 =Stringtonumber(s_TimeStamp1 );
Although you've used Now() in your example I'm assuming (based on your other question) that you in fact want a generic way of converting a timestamp string. To do such a conversion you have to do what I mentioned (including in my answer to your question) in the crib thread; you have to parse the string into day, month, year, hour etcetera components using the SubSt function. The date components will get you a serial date via the DayNo function, the time you have to work out for yourself as I described in this post. IBM has not provided a function for converting a timestamp string directly into a serial date value (Now() does not do this, it simply returns the current serial date and time), and StringToNumber certainly isn't that function. Your code isn't working because you're trying to take a shortcut that doesn't exist.
"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.
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
-
- Posts: 141
- Joined: Wed Mar 09, 2011 1:25 pm
- OLAP Product: TM1
- Version: 10.2.2
- Excel Version: 2003 2007 2010 2013
Re: Increasing Time by 8 hours
Aha well that answers that one,
Sorry Alan as I said I'm totally new to the time section, the most I've ever really done is dissect Today/now for parts of the date and time, in vb this would be a dodle but the tm1 functions are extremely complex I've been looking for examples all over the place and your write up is quite a head scratcher for a newby
Sorry Alan as I said I'm totally new to the time section, the most I've ever really done is dissect Today/now for parts of the date and time, in vb this would be a dodle but the tm1 functions are extremely complex I've been looking for examples all over the place and your write up is quite a head scratcher for a newby

-
- Posts: 141
- Joined: Wed Mar 09, 2011 1:25 pm
- OLAP Product: TM1
- Version: 10.2.2
- Excel Version: 2003 2007 2010 2013
Re: Increasing Time by 8 hours
Thank you all I will try the example above tomorrow appreciate the help all yet again this site comes thruDarkhorse wrote:Aha well that answers that one,
Sorry Alan as I said I'm totally new to the time section, the most I've ever really done is dissect Today/now for parts of the date and time, in vb this would be a dodle but the tm1 functions are extremely complex I've been looking for examples all over the place and your write up is quite a head scratcher for a newby
