PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • Range of dates
  • Managing the days and months
  • Handling the durations
  • Operators available for the days
  • Calculating the last day of the month
  • Calculating a payment date at 90 days (end of month)
  • Calculating the end of a 30-day period
  • Calculations on dates
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 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 is used to easily change dates (add a day, etc).
Reminder: Date items are used to manage:
  • "Year - Month - Day" dates (YYYYMMDD format).
  • "Year - Month - Day - Hours - Minutes - Seconds - Milliseconds" dates and times (YYYYMMDDHHmmSSCCC format).
  • "Number of days - Number of hours - Number of minutes - Number of seconds - Number of milliseconds" durations (+DHHMMSSCCC format).
Example
// 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
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.

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 was defined in the data model editor or with the Item Description type.

Modifying the day in a Date item Hide the details

<Data file>.<Item>.Day = <New day>
<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

Range of dates

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

Managing the days and months

Case 1: Direct assignment
During a direct assignment (for example, MyDay.Day = n), the day must be included 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: Operations on the days
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 limit: the 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 payment date at 90 days (end of month)

The Day property can be used to calculate a 90-day end-of-month 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.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment