ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage syntax / WLanguage types
  • Declaration and initialization
  • Properties available for the dates
  • Date ranges
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 Date type is used to easily manipulate dates. This type converts dates almost automatically (StringToDate, DateToString, IntegerToDate, DateToInteger, etc.).
This type can be used:
  • to get and manipulate HFSQL items in Date format.
  • to get and manipulate Date Edit controls.
  • in the WLanguage date management functions.
  • to perform calculations involving dates (subtraction, addition, etc.). For more details, see Operations available using the Date type.
The Date type supports null values. For more details, see Allowing nullable types.

Remarks:
  • Several properties can be used with the Date type, to retrieve only part of the date, for example.
  • For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
Example
StartDate is Date = 1205
EndDate is Date = "20011231"     // 31/12/2001
TodaysDate is Date = DateSys()
Syntax
<Variable name> is Date = <Value>
OR

<Variable name> is Date
<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 Date variable can be initialized with a value of one of the following types:
  • Date
  • DateTime: only the date will be taken into account.
  • String, in YYYYMMDD format (YYYY: year, MM: Month, DD: Day)
  • Integer: the date will correspond to the number of days passed between January 1st 1800 and the specified date.
By default, a Date variable is initialized with today's date (system date). To define the default value assigned to the Date, Time and DateTime variables, use DateTimeByDefault.
Remark: You also have the ability to initialize a Date variable with the system date by using Now.

Properties available for the dates

The following properties can be used with dates:
YearReturns or modifies an integer representing the year of the specified date.
DayReturns or modifies an integer representing the day of the specified date.
MonthReturns or modifies an integer representing the month of the specified date.

For more details on the possible operations on dates (addition, subtraction, comparison), see Operations available using the Date type.
StartDate is Date = "20011201"
// Adds 5 years to the date
StartDate.Year += 5
// Modifies the month
StartDate.Month = 5
// Calculates the end (30 days later)
let EndDate = StartDate
EndDate.Month++
EndDate.Day--

Date ranges

The Date type is used to manipulate dates between 01/01/0001 and 12/31/9999.
Remark: WLanguage functions and WLanguage properties make accurate calculations on dates from January 1st, 1583.
Related Examples:
Management of dates Unit examples (WINDEV): Management of dates
[ + ] Using the Date type of WLanguage and the functions for handling dates.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/28/2024

Send a report | Local help