Please enable JavaScript to view this site.

Codolex

Operations can be used to alter a date time and return a value or a new variable.

Uses System.DateUtils

Uses System.SysUtils

 

Operation

 

Increase +

Increases a date with a given value for a given time frame.

Available time frames: year, month, week, day, hour, minute, second

The amount that needs to be changed must be an integer value

 

Example: Date value: 2023-11-01 00:00:00 - Time frame: month - Increase number: 2

begin

var IncreasedDate: TDateTime;

 IncreasedDate := IncMonth(Date, 2);

end;

Result: 2024-01-01 00:00:00

 

To decrease a date value, use the increase operation with a negative number.

 

Start Of +

Get the start of the given time frame of the given date time.

Available time frames: year, month, week, day, hour, minute, second

 

Example:

Date value: 2024-12-31 02:04:10 - Time frame: week

begin

var StartOfDate: TDateTime;

 StartOfDate := StartOfTheWeek(Date);

end;

Result: 2024-12-30 00:00:00

 

EndOf +

Get the end of the given time frame of the given date time.

Available time frames: year, month, week, day, hour, minute, second

 

Example:

Date value: 2023-07-23 02:04:10 - Time frame: year

begin

var EndOfDate: TDateTime;

 EndOfDate := EndOfTheYear(Date);

end;

Result: 2023-12-31 23:59:59

© by GDK Software