ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage syntax / 
  • Declaration and initialization
  • Properties that can be used with DateTime variables
  • Time/date range
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
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.
The DateTime type supports null values. For more details, see Allowing nullable types.
Example
StartDate is DateTime = "202112311524"     // 31/12/2021 at 15:24
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

YearReturns or modifies an integer representing the year of the specified date.
TimeReturns or modifies an integer representing an hour.
DayReturns or modifies an integer representing the day of the specified date.
MillisecondReturns or modifies an integer representing the number of milliseconds.
MinuteReturns or modifies an integer representing the number of minutes.
MonthReturns or modifies an integer representing the month of the specified date.
DateReturns or modifies the date of the DateTime variable.
TimeReturns or modifies the time of the DateTime variable.
SecondReturns or modifies an integer representing the number of seconds.
StartDate is DateTime = "200112011530"
// Adds 5 years to the date
StartDate.Year += 5
// Modifies the month
StartDate.Month = 5
// Displays the date
Info("Date " + StartDate.Date)
// Displays the time
Info("Time " + StartDate.Time)

Time/date range

The DateTime type supports dates between 01/01/0001 at 00:00 and 12/31/9999 at 23:59.
Related Examples:
Calculations on durations 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
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 04/23/2024

Send a report | Local help