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 the days and months
  • Handling the durations
  • Operators available for the days
  • Calculating the last day of the month
  • Calculating a 90-day end-of-month due date
  • Calculating the end of a 30-day period
  • Calculations on dates
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
The Day property is used to:
  • Get the day from a Date or DateTime variable, or get the number of days from a Duration variable.
  • Change the day in a Date or DateTime variable, or change the number of days in a Duration variable.
  • Get the day or the number of days from a Date item (in "Date", "Date and Time" or "Duration" format).
    WEBDEV - Browser codePHP Not available.
  • Change the day or the number of days in a Date item (in "Date", "Date and Time" or "Duration" format).
    WEBDEV - Browser codePHP Not available.
Remark: The Day property simplifies date shifting operations (adding a day, etc.).
Reminder: Date items are used to handle:
  • 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
// Exemple sur une variable
DateDébut is Date = "20011225"
// Ajouter 5 jours à la date
DateDébut.Day += 5
// Modifier les jours
DateDébut.Day = 10
// Exemple sur une rubrique
Travail.DateDébut = "20011225"
// Ajouter 5 jours à la date
Travail.DateDébut.Jour += 5
// Modifier les jours
Travail.DateDébut.Jour = 10
Syntax

Finding out the day in a Date, DateTime or Duration variable Hide the details

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

Modifying the day in a Date, DateTime or Duration variable Hide the details

<Date>.Day = <New day>
<Date>: Date or DateTime
Name of the variable of type Date, DateTime or Duration to be used.
<New day>: Integer or character string
New day in digits (included between 1 and 31). Replaces the day in the specified date.
WEBDEV - Browser codePHP Not available in browser code and in PHP

Finding out the day in a Date item Hide the details

<Result> = <Data file>.<Item>.Day
<Result>: Integer
Day 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.
WEBDEV - Browser codePHP Not available in browser code and in PHP

Modifying the day in a Date item Hide the details

<Fichier de données>.<Rubrique>.day = <Nouveau jour>
<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 day>: Integer or character string
New day in digits (included between 1 and 31). Replaces the day 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 the days and months

Case 1: Direct assignment
When assigning directly (for example, MyDay.Day = n), the day must be between 1 and 31. A WLanguage error occurs if the specified day is incorrect.
The following syntax MyDay.Day = MyDay.Day + 5 may generate an error at runtime. For example, the following lines of code trigger an error:
// Code provoquant l'erreur
MaDate is Date = "20201126"   // le 26/11/2020 
MaDate.Day = MaDate.Day + 20   // Provoque une erreur WLangage car le jour est égal à 45
 
// Code correct
MaDate is Date = "20201126"   // le 26/11/2020 
MaDate.Day += 20

// Code provoquant l'erreur
MaDate is Date = "20201126"   // le 26/11/2020 
MaDate1 is Date 
MaDate1.Day = MaDate.Day + 20   // Provoque une erreur WLangage car le jour est égal à 45
 
// Code correct
MaDate1 = MaDate   // le 26/11/2020 
MaDate1.Day += 20
Case 2: Day operations
When performing operations on the dates, the change of month is automatically managed. Therefore, if the number of days is greater than the number of days in the month, the number of days restarts from 1 and the number of the month is automatically modified. The year is also modified if necessary (month of December for instance).
For example:
DateDébut is Date = "20201226"   // Le 26/12/2020
// Ajouter 10 jours à la date
DateDébut.Day +=10    // DateDébut vaut "20050105"

Handling the durations

A duration has no limits: its number of days can exceed 30 or 31 days.

Operators available for the days

The following arithmetic operators can be used with the Day property:
  • ++ and --
  • += and - =
DateDébut is Date = "20201126"   
DateDébut.Day++     // Ajouter 1 jour à la date
DateDébut.Day+=5    // Ajouter 5 jours à la date
DateDébut.Day-=5    // Retrancher 5 jours à 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 property Day PROPERTY property is used to calculate the end date of a 90-day month-end 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--

Calculations on dates

The date storage format allows you to store dates from 01/01/0001 to 12/31/9999.
WLanguage functions and WLanguage properties make accurate calculations on dates from January 1st, 1583.
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