Darkhorse wrote:wo there alan,
I said i had stripped the values from the string to a simple string without the ":" and "-" (apologies from putting a 6 in my example unfortuantely I cant seem to copy and paste from my TM1 directly into here (sometimes it works sometimes it doesnt)
[Ctrl]+[C] multiple times, or use the Copy on the edit menu. If you can't paste it odds are that you aren't really copying it in the first place, which is a known issue in some of the TM1 GUIs.
Darkhorse wrote:I have a problem where I need to take time away from time but both are in a string value, I have stripped it down to this:
fist time
20131010145020
and I said
I have read alan Kirks info on time and seen dayno is good for getting a serial number but the example only shows using a date going in to it, I have tried many converisons of DayNo but I cannot get a time string in there as well
And why did the example only show a date going into it? Because both Iboglix and I were too lazy to use a time example as well? Because it's a good secret that we decided to keep for ourselves? Or possibly it's because, as the function name (
DayNo) implies and the documentation is pretty unambiguous about... it
only works with dates; whole days. Note the complete absence of arguments for passing time components to the function. You're getting 19601010000000 because if you're trying to pass in a time component it's evaluating as a bogus date and coming out as zero.
Darkhorse wrote:The Value that i said gets returned from Date is 19601010000000 when i tried with coding, Apologies Alan but to get things wrong but its good to try and find a result to fix it, I have been through most of the help file and tried every possible option to turn a string (it can be altered) to a serial value so I can do a simple calculation one time minus second time equals difference is what im looking for.
I understand what your writing in the date time write up 6am is .25 of a day so 1/4 but I was wondering if there was a way to do the times directly as I need to find a way to find the minutes and secondshow does that work?
so really im looking for this
14:50:20-14:45:02 = 5:18
I added the date to the time to create the ability to 1 possible put it into a capsule to create a serial and 2 catch anything that went over the 12am time line
One other thing that I said is that:
I wrote:
Both Excel and TM1 provide functions for obtaining serial dates and times. TM1's set is more limited (and generally more focussed on date to string conversions and vice versa while Excel's tend to be more "value- (numeric) oriented), but many of them have equivalents in some form or another.
Many, not all.
I told you in the reply to your July question (which was in its essence pretty much the same question as this one) that the
only option you had to work with timestamps like this was to parse the strings and do the maths. You seem to have a reluctance to do that.
The following is a fully worked example. You can simplify it, you can put it in a generic TI process that can pass back the result through global variables, you can even convert it from a TI to a rules-based value in a control cube. What you
cannot do is avoid doing the parsing and calculations in some fashion. Not until or unless Iboglix releases some new TI functions to do this conversion automatically for you, which I wouldn't hold my breath for.
Code: Select all
dbl_1Hour = 1/24;
dbl_1Minute = dbl_1Hour\60;
dbl_1Second = dbl_1Minute\60;
l_SecondsIn1Day = 60*60*24;
#--------------------------------------------------------------------------------------
s_TimeFirst = '20131010145020';
s_DayFirst = Subst( s_TimeFirst, 1, 4) | '-' | Subst( s_TimeFirst, 5, 2) | '-' | Subst( s_TimeFirst, 7, 2);
l_DayFirst = DayNo(s_DayFirst);
s_HoursFirst = Subst( s_TimeFirst, 9, 2);
s_MinutesFirst = Subst( s_TimeFirst, 11, 2);
s_SecondsFirst = Subst( s_TimeFirst, 13, 2);
dbl_HoursFirst = Numbr( s_HoursFirst) * dbl_1Hour;
dbl_MinutesFirst = Numbr( s_MinutesFirst) * dbl_1Minute;
dbl_SecondsFirst = Numbr( s_SecondsFirst) * dbl_1Second;
dbl_FirstDayTime = l_DayFirst + dbl_HoursFirst + dbl_MinutesFirst + dbl_SecondsFirst;
#--------------------------------------------------------------------------------------
s_TimeSecond = '20131010145059';
s_DaySecond = Subst( s_TimeSecond, 1, 4) | '-' | Subst( s_TimeSecond, 5, 2) | '-' | Subst( s_TimeSecond, 7, 2);
l_DaySecond = DayNo(s_DaySecond);
s_HoursSecond = Subst( s_TimeSecond, 9, 2);
s_MinutesSecond = Subst( s_TimeSecond, 11, 2);
s_SecondsSecond = Subst( s_TimeSecond, 13, 2);
dbl_HoursSecond = Numbr( s_HoursSecond) * dbl_1Hour;
dbl_MinutesSecond = Numbr( s_MinutesSecond) * dbl_1Minute;
dbl_SecondsSecond = Numbr( s_SecondsSecond) * dbl_1Second;
dbl_SecondDayTime = l_DaySecond + dbl_HoursSecond + dbl_MinutesSecond + dbl_SecondsSecond;
#--------------------------------------------------------------------------------------
dbl_Difference = dbl_SecondDayTime - dbl_FirstDayTime;
l_Seconds = Round( dbl_Difference * l_SecondsIn1Day);
AsciiOutput('F:\Temp\Time.txt', Trim (Str( l_Seconds, 12, 0 ) ) | ' seconds');