ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage properties / Time and date management properties
  • Date ranges
  • Managing months and years
  • Operators available for the months
  • Calculating the last day of the month
  • Calculating a 90-day end-of-month due date
  • Calculating the end of a 30-day period
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
The Month property is used to:
  • Retrieve the month from a variable of type Date or DateTime.
  • Modify the month of a variable of type Date or DateTime.
  • Retrieve the month from a Date item (in "Simple date" or "Date and Time" format).
  • Modify the month in a Date item (in "Simple Date" or "Date and Time" format).
Remark: The Month property simplifies date shifting operations (adding a month, etc.).
Reminder Date fields can be used to manage:
  • simple dates: "Year - Month - Day" (YYYYMMDD format)
  • dates and times: "Year - Month - Day - Hours - Minutes - Seconds - Milliseconds" (YYYYMMDDHHmmSSCCC format)
  • durations: "Number of days - Number of hours - Number of minutes - Number of seconds - Number of milliseconds" (+DHHMMSSCCC format)
Example
// Manipulations sur une variable de type Date
DateDébut is Date = "20011212"
// Ajouter 1 mois à la date
DateDébut.Month++
// Modifier le mois
DateDébut.Month = 5
// Manipulations sur une rubrique
Travail.DateDébut = "20011212"
// Ajouter 1 mois à la date
Travail.DateDébut.Mois++
// Modifier le mois
Travail.DateDébut.Mois = 5
Syntax

Getting the month in a Date or DateTime variable Hide the details

<Result> = <Date>.Month
<Result>: Integer
Month on 2 digits.
<Date>: Date or DateTime
Name of the variable of type Date or DateTime to be used.

Modifying the month in a Date or DateTime variable Hide the details

<Date>.Month = <New month>
<Date>: Date or DateTime
Name of the variable of type Date or DateTime to be used.
<New month>: Integer or character string
New month expressed in numbers (included between 1 and 12). Replaces the month in the specified date.

Finding out the month in a Date item (in "Simple date" or "Date and Time" format) Hide the details

<Result> = <Data file>.<Item>.Month
<Result>: Integer
Month on 2 digits.
<Data file>: Character string
Name of the data file used. This name was defined in the data model editor or with the File Description type.
<Item>: Character string
Name of the item used. This name is defined in the data model editor or with the Item Description type.

Modifying the month in a Date item (in "Simple date" or "Date and Time" format) Hide the details

<Fichier de données>.<Rubrique>.Month = . <Nouveau mois>
<Data file>: Character string
Name of the data file used. This name was defined in the data model editor or with the File Description type.
<Item>: Character string
Name of the item used. This name was defined in the data model editor or with the Item Description type.
<New month>: Integer or character string
New month expressed in numbers (included between 1 and 12). Replaces the month in the specified date.
Remarks

Date ranges

The Date and DateTime types are used to handle dates from 01/01/0001 to 12/31/9999.

Managing months and years

Case 1: Direct assignment
When assigning directly (for example, MyWork.MyDate.Month = n), the month must be between 01 and 12. A WLanguage error occurs if an invalid month is specified.
The notation MyJob.MyDate.Month = MyJob.MyDate.Month + 5 may generate a runtime error. For example, the following lines of code trigger an error:
// Code provoquant l'erreur
MaDate is Date = "20201126"	// le 26/11/2020 
MaDate.Month = MaDate.Month + 2 
// Provoque une erreur WLangage car le mois est égal à 13
 
// Code correct
MaDate is Date = "20201126"	// le 26/11/2020
MaDate.Month += 2

// Code provoquant l'erreur
MaDate is Date = "20201126"	// le 26/11/2020
MaDate1 is Date 
MaDate1.Month = MaDate.Month + 2
// Provoque une erreur WLangage car le mois est égal à 13
 
// Code correct
MaDate1 = MaDate	// le 26/11/2020 
MaDate1.Month += 2

Case 2: Operations on months
When performing operations on the dates, the change of year is automatically managed. Therefore, if the number of months is greater than 12, the year is automatically modified and the number of months restarts from 1.
For example:
DateDébut is Date = "20201226"	// Le 26/12/2020
// Ajouter 5 mois à la date
DateDébut.Month += 5	// DateDébut vaut "20210526"

Operators available for the months

The following arithmetic operators can be used with the Month property:
  • ++ and --
  • += and - =
DateDébut is Date = "20201126"   
DateDébut.Month++	// Ajouter 1 mois à la date
DateDébut.Month+=5	// Ajouter 5 mois à la date
DateDébut.Month-=5	// Retrancher 5 mois à la date

Calculating the last day of the month

To get the last day of a month, simply assign 31 to the Day property of the date. The last day will be automatically calculated according to the specified month.
DateDébut is Date = "20201126"   
DateDébut.Day = 31    
// La date 31 est impossible pour le mois de novembre
// Elle est automatiquement remplacée par 30

Calculating a 90-day end-of-month due date

The Day property can be used to calculate a 90-day end-of-month due date.
MaDate is Date = "20201126"   
MaDate.Day += 90    
MaDate.Day = 31

Calculating the end of a 30-day period

A 30-day period corresponds to a one-month period from a given date. The Month and Day properties can be used to easily calculate the end date of a 30-day period.
DateDébut is Date = "20201126"   
DateFin is Date = DateDébut
DateFin.Month++    
DateFin.Day--
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: 05/13/2025

Send a report | Local help