Help / WLanguage / WLanguage syntax / Data types
  • Declaration and initialization
  • Properties that can be used on the DateTime variables
  • Interval of data
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Stored procedures
The DateTime type is used to easily handle a date and a time. The DateTime type can be used to perform calculations (subtraction, addition, ...) on the dates, times and durations. For more details, see Operations that can be performed on the DateTime type.
  • Several properties can be used with the DateTime type, to retrieve the date or the time, a part of the date or a 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 = "200112311524"     // 31/12/2001 at 15:24

Declaration and initialization

  • A DateTime variable can be initialized with a value of the following type:
    • Date: the hours and the minutes will be initialized to 0.
    • DateTime
    • Character string, in the following format
      • YYYYMMDD
      • YYYYMMDDHHmm
        (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 also have the ability to initialize a DateTime variable with the system date and time by using Now.

Properties that can be used on the DateTime variables

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

Interval of data

The DateTime type is used to manage data included 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…
Click [Add] to post a comment

Last update: 06/22/2023

Send a report | Local help