Time less/Add minutes  [SOLVED]

Questions about MultiCharts and user contributed studies.
faraz
Posts: 144
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 57 times

Time less/Add minutes

Postby faraz » 29 Nov 2013

Hi,

I want to less 50 minutes from time =1030
So the answer should come 940
Or if i add 50 minutes then answer should come 1120

How can I do this?

I tried this but no luck

Code: Select all

minutestotime(timetominutes(t-50))
Thanks

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1542 times
Been thanked: 1565 times
Contact:

Re: Time less/Add minutes

Postby JoshM » 29 Nov 2013

How can I do this?
You have to convert that to DateTime first. See this thread for an example/idea.

faraz
Posts: 144
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 57 times

Re: Time less/Add minutes

Postby faraz » 29 Nov 2013

You have to convert that to DateTime first. See this thread for an example/idea.


Great thanks,,, This is the formula

Code: Select all

DateTime2ELTime(ELTimeToDateTime(t)-ELTimeToDateTime(60))


But one problem this formula works for 99 minutes only. Above that it gave wrong time. Why is that?

User avatar
TJ
Posts: 7739
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1032 times
Been thanked: 2221 times

Re: Time less/Add minutes

Postby TJ » 29 Nov 2013

Hi,
I want to less 50 minutes from time =1030
So the answer should come 940
Or if i add 50 minutes then answer should come 1120
How can I do this?
I tried this but no luck

Code: Select all

minutestotime(timetominutes(t-50))
Thanks
Please see post #12
Manipulating Dates and Times .... pg. 15
viewtopic.php?f=16&t=6929

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1542 times
Been thanked: 1565 times
Contact:

Re: Time less/Add minutes

Postby JoshM » 29 Nov 2013

(Misunderstood)
Last edited by JoshM on 01 Dec 2013, edited 1 time in total.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: Time less/Add minutes

Postby bowlesj3 » 29 Nov 2013

TJ had a great idea. I should find the time to read it myself. Rereading is very powerful when you are right ready to use what you read.

I think your forumula

Code: Select all

minutestotime(timetominutes(t-50))
Should be replaced with this.

Code: Select all

minutestotime(timetominutes(time) - 50)
I used this all over the place and it works. The command "timetominutes(time)" converts the EL format to a numerical representation of time. I think it is a century representation which would be the number of minutes since the beginning of the 1900 century (I would have to double check). Then you subtract 50 minutes to get a new century number. Next the command "minutestotime(Your new century Number)" converts this number back to EL format. Give this a try and see what happens.

After reading what TJ suggested you might want to read all of this thead too.
viewtopic.php?f=16&t=10411

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: Time less/Add minutes

Postby bowlesj3 » 29 Nov 2013

It is interesting to study the function "timetominutes" shown below.

Code: Select all

inputs: XTime( numericsimple ) ;

Value1 = XTime * .01 ;

TimeToMinutes = 60 * IntPortion( Value1 ) + 100 * FracPortion( Value1 ) ;
It appears I was wrong. It is not converting the number fo a century number. It appears to be converting it to a number which is the number of minutes since midnight rather than the number of minutes since the beginning of the century. I have never tried this function across a day. It may not work if you are subtracting 50 from a time that is just after midnight and you are looking for the time in the prior day. It would be worth a test.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: Time less/Add minutes

Postby bowlesj3 » 29 Nov 2013

Nop. It does work. I just duplicated the code from the two functions "MinutesTotime" and "TimeToMinutes" into excel and did a test. What I did in excel would be entered like this in EL code.

Code: Select all

OutputTime = MinutesToTime(TimeToMinutes(110)-80)
And the Outputtime (using my excel version of these two functions working together) was given a value of 2350 (meaning 23 hours and 50 minutes) which is correct. So in other words subtract 80 minutes from 10 minutes after 1am and you will get 50 minutes past 11pm (from the day before of course). Fun stuff.

User avatar
TJ
Posts: 7739
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1032 times
Been thanked: 2221 times

Re: Time less/Add minutes

Postby TJ » 29 Nov 2013

You can use a function called AddTime.
It should be in your PowerLanguageEditor.

eg.

Code: Select all

var:
new.time(0);

new.time = AddTime( 1030, -50 );

faraz
Posts: 144
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 57 times

Re: Time less/Add minutes

Postby faraz » 30 Nov 2013

You can use a function called AddTime.
It should be in your PowerLanguageEditor.

eg.

Code: Select all

var:
new.time(0);

new.time = AddTime( 1030, -50 );
TJ
AddTime function is not available in MC v8.8 beta2.
Could you please post that code on this forum.

Thanks

User avatar
TJ
Posts: 7739
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1032 times
Been thanked: 2221 times

Re: Time less/Add minutes  [SOLVED]

Postby TJ » 30 Nov 2013

You can use a function called AddTime.
It should be in your PowerLanguageEditor.

eg.

Code: Select all

var:
new.time(0);
new.time = AddTime( 1030, -50 );
TJ
AddTime function is not available in MC v8.8 beta2.
Could you please post that code on this forum.
Thanks
Please see:
viewtopic.php?f=5&t=45762

faraz
Posts: 144
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 57 times

Re: Time less/Add minutes

Postby faraz » 30 Nov 2013

You can use a function called AddTime.
It should be in your PowerLanguageEditor.

eg.

Code: Select all

var:
new.time(0);
new.time = AddTime( 1030, -50 );
TJ
AddTime function is not available in MC v8.8 beta2.
Could you please post that code on this forum.
Thanks
Please see:
viewtopic.php?f=5&t=45762
TJ

Thank you, This function works like a charm.

User avatar
TJ
Posts: 7739
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1032 times
Been thanked: 2221 times

Re: Time less/Add minutes

Postby TJ » 30 Nov 2013

TJ
Thank you, This function works like a charm.
You are welcome.

Your original formula was not that far off... only missed by one bracket.


Return to “MultiCharts”