TurboDB Engine Documentation
TurboPL Date and Time Operators and Functions
|Previous Top Next|
These date and time operators and functions can be used in TurboPL expressions. They are no more recommended for TurboSQL.
All numeric comparison operators can be used for time, date and datetime values as well. E.g. Date1 > Date2 if and only if Date1 designates a point in time later then Date2.
You can add time spans to dates, subtract time spans from dates and subtract dates from each other to get the time span. The time span is a real number, which indicates the number of days (including a fractional part for the time of day) when calculating with dates and datetimes or the number of minutes (including a fractional part for the seconds and milliseconds) when calculating with times.
If Time1 and Time2 are time values, Date1 and Date2 date values, DateTime1 and DateTime2 datetime variables and TimeSpan1, TimeSpan2 real variables, then the following expressions are meaningful:
Time2 - Time1
Time2 - TimeSpan1
Time1 + TimeSpan2
Date2 - Date1
Date2 - TimeSpan1
Date2 + TimeSpan2
DateTime2 - DateTime1
DateTime2 - TimeSpan1
DateTime2 - TimeSpan2
Beyond the numeric operators and functions there are also special date and time functions:
CombineDateTime(ADate: Date; ATime: Time): DateTime
Puts a date and a time together to form a datetime.
DateStr(ADateTime: DateTime): String
Converts a date or a time stamp into a string according to the current date format.
DateTimeStr(ADateTime: DateTime; TimePrecision: Integer): String
Converts a time stamp into a string according to the current date and time format. TimePrecision indicates the number of time parts to create (minute = 2, second = 3, millisecond = 4)
Day(ADate: DateTime): Integer
Extracts the day out of a date.
DayOfWeek(ADateTime: DateTime): String
Returns the name of the day of the week in the current locale (e.g. Wednesday)
Hour(ADate: DateTime): Integer
Extracts the hour from a time or datetime.
Millisecond(ADate: DateTime): Integer
Extracts the millisecond from a time or datetime.
Minute(ADate: DateTime): Integer
Extracts the minute from a time or datetime.
Month(ADate: DateTime): Integer
Extracts the month out of a date.
Returns the current time.
Second(ADate: DateTime): Integer
Extracts the second from a time or datetime.
TimeStr(ATime: Time): String
Converts a time or time stamp into a string according to the current time format.
Returns the current date
Week(ADate: DateTime): Integer
Returns the number of the calendar week within the year.
WeekDayNo(ADateTime: DateTime): Integer
Returns the day of week as a number between 1 (Monday) and 7 (Sunday)
Year(ADate: DateTime): Integer
Extracts the year out of a date.
TurboPL is supported only for backward compatibility in tables up to level 4.