hello,
i found nothing about in the help.
i need a function that allows me to add an hour or minute, etc, to
a given datetime and that returns a valid date.
any idea other than using an external DLL in order to solve this,
is welcome.
thank you
arithmetical datetime operations
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times
get the Easylanguage manual
http://www.tssupport.com/support/tutorials/
look under:
Manipulating Date and Time.
there are examples and explanations.
key concepts to understand:
-- Julian time
-- EL time
-- real time
-- computer time
http://www.tssupport.com/support/tutorials/
look under:
Manipulating Date and Time.
there are examples and explanations.
key concepts to understand:
-- Julian time
-- EL time
-- real time
-- computer time
Last edited by TJ on 27 Jan 2009, edited 1 time in total.
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times
TJ,
Is there any way to get or write a function that returns the most recent price field update with a high precision (not minute but second).
I know there is such a thing like TradeTime (with minute precision) but a need something like TradeTime_s (second precision) or TradeTime_ms (milisecond precision).
Would it be possible with EL?
Regards
Is there any way to get or write a function that returns the most recent price field update with a high precision (not minute but second).
I know there is such a thing like TradeTime (with minute precision) but a need something like TradeTime_s (second precision) or TradeTime_ms (milisecond precision).
Would it be possible with EL?
Regards
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times
you are talking about Time & Sales.TJ,
Is there any way to get or write a function that returns the most recent price field update with a high precision (not minute but second).
I know there is such a thing like TradeTime (with minute precision) but a need something like TradeTime_s (second precision) or TradeTime_ms (milisecond precision).
Would it be possible with EL?
Regards
I don't think MC has that.
Marina,you are talking about Time & Sales.TJ,
Is there any way to get or write a function that returns the most recent price field update with a high precision (not minute but second).
I know there is such a thing like TradeTime (with minute precision) but a need something like TradeTime_s (second precision) or TradeTime_ms (milisecond precision).
Would it be possible with EL?
Regards
I don't think MC has that.
Is it possible in MC?
Regards
Hello TJ,
finally got it, thank you:
inputs: ELTime(NumericSimple),GMTOffset(NumericSimple);
variables: NewTime(0);
NewTime = ELTimeToDateTime(ELTime) + GMTOffset / 24.0;
TimeShiftGmt = DateTime2ElTime(NewTime );
(to MC team, allow me to mention:
ELTimeToDateTime
and
DateTime2ElTime
(2 <-> to)
is no good style in order to provide intuitive programming.)
finally got it, thank you:
inputs: ELTime(NumericSimple),GMTOffset(NumericSimple);
variables: NewTime(0);
NewTime = ELTimeToDateTime(ELTime) + GMTOffset / 24.0;
TimeShiftGmt = DateTime2ElTime(NewTime );
(to MC team, allow me to mention:
ELTimeToDateTime
and
DateTime2ElTime
(2 <-> to)
is no good style in order to provide intuitive programming.)
This may help. It works for time only. However for time it does not work from one day to the next. It does work over the midnight however. You can extract whatever you want from it or use the function as is to make it easier to remember if you need a lot of time calculations.
Here is the caller test.
Code: Select all
{A_TimeAddSub_s}
{
Result_s = A_TimeAddSub_s(Time_s, "A", 1, "S");
Result_s = A_TimeAddSub_s(Time_s, "A", 5, "M");
Result_s = A_TimeAddSub_s(Time_s, "A", 3, "H");
Result_s = A_TimeAddSub_s(Time_s, "A", 3, "H");
Result_s = A_TimeAddSub_s(Time_s, "S", 1, "H");
}
inputs:
TimeIn(NumericSimple),
AddSub(StringSimple),
UnitsIn(NumericSimple),
UnitsToAdd(StringSimple);
variables:
AddSubAmt(0),
OneHour(1/24), {1 divided by the number of hours in a day}
OneMinute(1/1440), {1 divided by the number of minutes in a day}
OneSecond(1/86400); {1 divided by the number of seconds in a day}
if AddSub = "A" then
AddSubAmt = 1;
if AddSub = "S" then
AddSubAmt = -1;
if AddSubAmt = 0 then
A_TimeAddSub_s = 0
else
begin
if UnitsToAdd = "S" then
A_TimeAddSub_s = DateTime2ELTime_s(ELTimeToDateTime_s(TimeIn) + ((UnitsIn * OneSecond) * AddSubAmt));
if UnitsToAdd = "M" then
A_TimeAddSub_s = DateTime2ELTime_s(ELTimeToDateTime_s(TimeIn) + ((UnitsIn * OneMinute) * AddSubAmt));
if UnitsToAdd = "H" then
A_TimeAddSub_s = DateTime2ELTime_s(ELTimeToDateTime_s(TimeIn) + ((UnitsIn * OneHour) * AddSubAmt));
end;
Code: Select all
Print( File("C:\Access\A_DateTimeLearningTests1.txt"),
" Time_s", " " ,
Time_s, " --- " ,
" add 1Sec", " " ,
A_TimeAddSub_s(Time_s,"A", 1, "S") , " " ,
" add 1min", " " ,
A_TimeAddSub_s(Time_s,"A", 1, "M") , " " ,
" add 1hour", " " ,
A_TimeAddSub_s(Time_s,"A", 1, "H") , " " ,
" subtract 1Sec", " " ,
A_TimeAddSub_s(Time_s,"S", 1, "S") , " " ,
" subtract 1min", " " ,
A_TimeAddSub_s(Time_s,"S", 1, "M") , " " ,
" subtact 1hour", " " ,
A_TimeAddSub_s(Time_s,"S", 1, "H") , " " ,
" ");