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.

Comparison

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.

Calculations

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:

Function |
Description |

CombineDateTime(ADate: Date; ATime: Time): DateTime |
Puts a date and a time together to form a datetime. |

Day(ADate: DateTime): Integer |
Extracts the day out of a date. |

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. |

Now: Time |
Returns the current time. |

Second(ADate: DateTime): Integer |
Extracts the second from a time or datetime. |

Today: Date |
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. |

Compatibility Information

TurboPL is supported only for backward compatibility in tables up to level 4.