|
|
|
|
|
- Declaration and initialization
- Properties that can be used with DateTime variables
- Time/date range
DateTime (Variable type) In french: DateHeure
The DateTime type allows you to manipulate dates and times. The DateTime type can be used to perform calculations (sum, difference, etc.) on dates, times and durations.. For more details, see Operations available with the DateTime type. Remarks: - Several properties can be used with the DateTime type, to extract only the date or time, part of the date or part of the time.
- For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
StartDate is DateTime = "202112311524"
Syntax
<Variable name> is DateTime = <Value> OR
<Variable name> is DateTime <Variable name> = <Value>
<Variable name>: Name of the variable to declare. When several variables of the same type are declared and initialized on the same line, only the last variable is initialized. <Value>: Variable initialization value (See Remarks). Remarks Declaration and initialization - A DateTime variable can be initialized with a value of the following type:
- Date: hours and minutes will be initialized to 0.
- DateTime
- String, in the following format
- YYYYMMDD
- YYYYMMDDHH
- YYYYMMDDHHmm
- YYYYMMDDHHmmSS
- YYYYMMDDHHmmSSCC
- YYYYMMDDHHmmSSCCC
(YYYY: year, MM: month, DD: Day, HH: hour, mm: minutes, SS: seconds, CC: hundredths of a second, CCC: Thousandths of a second)
- By default, a DateTime variable is initialized with today's date (system date) and with the system time. To define the default value assigned to the Date, Time and DateTime variables, use DateTimeByDefault.
Remark: You can also initialize a DateTime variable with the system date and time using Now. Properties that can be used with DateTime variables | | Year | Returns or modifies an integer representing the year of the specified date. | Time | Returns or modifies an integer representing an hour. | Day | Returns or modifies an integer representing the day of the specified date. | Millisecond | Returns or modifies an integer representing the number of milliseconds. | Minute | Returns or modifies an integer representing the number of minutes. | Month | Returns or modifies an integer representing the month of the specified date. | Date | Returns or modifies the date of the DateTime variable. | Time | Returns or modifies the time of the DateTime variable. | Second | Returns or modifies an integer representing the number of seconds. |
StartDate is DateTime = "200112011530"
StartDate.Year += 5
StartDate.Month = 5
Info("Date " + StartDate.Date)
Info("Time " + StartDate.Time)
The DateTime type supports dates between 01/01/0001 at 00:00 and 12/31/9999 at 23:59.
Related Examples:
|
Unit examples (WINDEV): Calculations on durations
[ + ] Calculations on dates and times with the WLanguage functions: - Calculate the duration between two moments (dates and times) - Calculate a sum of durations - Calculate an average of durations
|
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|