AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Propiedades WLanguage / Propiedades de gestión de fechas y horas
  • 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
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
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).
  • Change the day or the number of days in a Date item (in "Date", "Date and Time" or "Duration" format).
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).
Ejemplo
// Example on a variable
StartDate is Date = "20011225"
// Add 5 days to the date
StartDate.Day += 5
// Modify the days
StartDate.Day = 10
// Example on an item
Work.StartDate = "20011225"
// Add 5 days to the date
Work.StartDate.Day += 5
// Modify the days
Work.StartDate.Day = 10
Sintaxis

Finding out the day in a Date, DateTime or Duration variable Ocultar los detalles

<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 Ocultar los detalles

<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.

Finding out the day in a Date item Ocultar los detalles

<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.

Modifying the day in a Date item Ocultar los detalles

<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.
Observaciones

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 triggering the error
MyDate is Date = "20201126"   // 11/26/2020 
MyDate.Day = MyDate.Day + 20   // Triggers a WLanguage error because the day is equal to 45
 
// Correct code
MyDate is Date = "20201126"   // 11/26/2020 
MyDate.Day += 20

// Code triggering the error
MyDate is Date = "20201126"   // 11/26/2020 
MyDate1 is Date 
MyDate1.Day = MyDate.Day + 20   // Triggers a WLanguage error because the day is equal to 45
 
// Correct code
MyDate1 = MyDate   // 11/26/2004 
MyDate1.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:
StartDate is Date = "20201226"   // 12/26/2020
// Add 10 days to the date
StartDate.Day +=10    // StartDate is "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 - =
StartDate is Date = "20201126"   
StartDate.Day++     // Add 1 day to the date
StartDate.Day+=5    // Add 5 days ot the date
StartDate.Day-=5    // Subtract 5 days to the 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.
StartDate is Date = "20201126"   
StartDate.Day = 31    
// November does not have 31 days
// The day is automatically replaced with 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.
MyDate is Date = "20201126"   
MyDate.Day += 90   
MyDate.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.
StartDate is Date = "20201126"   
EndDate is Date = StartDate
EndDate.Month++    
EndDate.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.
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 13/05/2025

Señalar un error o enviar una sugerencia | Ayuda local