The following lists alphabetically built-in functions available for working with date and time.
These functions are placed in DateTime package.
| CompareDates | GetDate | Month |
| CompareTime | GetShortYear | Now |
| DateValue | GetTicks | Seconds |
| Day | GetTime | TimeValue |
| DayOfWeek | Hour | Year |
| DayOfYear | Minute |
| Java time and .Net time The application based on Java platform use the January 1, 1970 00:00:00.000 GMT as start point for calc time. It likes Unix/Linux system time or many other platforms (example, MQL4). But, MS .Net (and so PTL Builder) uses the January 1, 0001 00:00:00.000 GMT as start point for calc time. So, the Java time must be converted with special functions for correct applied in .Net application. |
CompareDates
Compares two dates and returns 0 if they are the same, -1 if the first one is earlier than the first one, and 1 if the first one is later.
Syntax
Parameters
Example
int n;
n = CompareDates( AddYears(Now(), 2), Now()); // n <- 1
n = CompareDates ( AddMinutes(Now(), 2), Now()); // n <- 0
CompareTime
Compares two time values and returns 0 if they are the same, -1 if the first one is earlier than the first one, and 1 if the first one is later.
Syntax
Parameters
Example
int n;
n = CompareTime( AddYears(Now(), 2), Now()); // n <- 0
n = CompareTime( AddMinutes(Now(), 2), Now()); // n <- 1
DateValue
Returns the datetime value for specific year, month and day.
Syntax
Day
Returns the day of month for current locale time
Syntax
int Day() |
Parameters
None
Example
int dt;
dt = Day(); // dt <- 25 for April 25
dt = Day(); // dt <- 8 for June 8
DayOfWeek
Returns the day of week for current locale time, BUT the first day of week is SUNDAY
Syntax
int DayOfWeek() |
Example
int dt;
dt = DayOfWeek(); // dt <- 6 for Friday, April 25 2008
dt = DayOfWeek(); // dt <- 4 for Wednesday, June 25 2008
DayOfYear
Returns the day of year for current locale time.
Syntax
int DayOfYear() |
Example
int dt;
dt = DayOfYear(Now());
GetDate
Returns the date from the datetime value.
Syntax
Parameters
Example
int dt;
dt = GetDate(Now());
GetShortYear
Returns the current year in short representation.
Syntax
int GetShortYear() |
Parameters
none
Example
int dt;
dt = GetShortYear();
GetTicks
Returns the ticks from Jan 1, 1970 as double.
Syntax
double GetTicks() |
Example
double dt;
dt = GetTicks();
GetTime
Returns the time for specified value.
Syntax
Parameters
Example
datetime dt;
dt = GetTime( Now() ); // n <- 483696875000 for 633447267696875000
Hour
Returns the hours for current locale time
Syntax
int Hour() |
Parameters
None
Example
int dt;
dt = Hour(); // dt <- 10 for 10 Hours
Minute
Returns the minutes for current locale time
Syntax
int Minute() |
Parameters
None
Example
int dt;
dt = Minute(); // dt <- 33 for 33 Minutes
Month
Returns the months of year for current date
Syntax
int Month() |
Parameters
Example
double dt;
dt = Month();
Now
Function returns datetime value as a milliseconds value represents the number of milliseconds that have passed since January 1, 0001 year 00:00:00.000 GMT (.Net time).
Syntax
datetime Now() |
Example
datetime dt;
dt = Now();
Seconds
Returns the seconds for current locale time
Syntax
int Seconds() |
Example
double dt;
dt = Seconds(); // dt <- 33 for 33 seconds
TimeValue
Function creates and returns datetime value as a milliseconds value represents the number of milliseconds that have passed since January 1, 0001 year 00:00:00.000 GMT (.Net time).
Syntax
datetime TimeValue( int year, int month, int day, int hour, int minute, int second) |
Parameters
Example
datetime dt;
dt = TimeValue(2008, 7, 4, 12, 0, 0); // dt <- 633507696000000000
Year
Returns the year for current locale time
Syntax
int Year() |
Parameters
None
Example
int dt;
dt = Year(); // dt <- 2008 for 2008 year