PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Range of dates
  • Managing the months and years
  • Operators available for the months
  • Calculating the last day of the month
  • Calculating a payment date at 90 days (end of month)
  • Calculating the end of a floating month
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
..Month is used to:
  • Retrieve the month from a Date or DateTime variable.
  • Modify the month in a Date or DateTime variable.
  • Retrieve the month from a Date item (in "Simple date" or "Date and Time" format).
    WEBDEV - Browser code Not available.
  • Modify the month in a Date item (in "Simple Date" or "Date and Time" format).
    WEBDEV - Browser code Not available.
Note: ..Month simplifies the operations performed on dates (add a month, etc.).
Reminder: The Date items are used to manage:
  • the simple dates "Year - Month - Day" (YYYYMMDD format)
  • the dates and times "Year - Month - Day - Hours - Minutes - Seconds - Milliseconds" (YYYYMMDDHHMMSSLLL format)
  • the durations "Number of days - Number of hours - Number of minutes - Number of seconds - Number of milliseconds" (+DHHMMSSLLL format)
Versions 16 and later
Universal Windows 10 App This property is now available for the Windows Phone applications.
New in version 16
Universal Windows 10 App This property is now available for the Windows Phone applications.
Universal Windows 10 App This property is now available for the Windows Phone applications.
Versions 17 and later
iPhone/iPad This property is now available for the iPhone/iPad applications.
New in version 17
iPhone/iPad This property is now available for the iPhone/iPad applications.
iPhone/iPad This property is now available for the iPhone/iPad applications.
Versions 18 and later
Universal Windows 10 App This property is now available in Windows Store Apps mode.
New in version 18
Universal Windows 10 App This property is now available in Windows Store Apps mode.
Universal Windows 10 App This property is now available in Windows Store Apps mode.
Versions 20 and later
WEBDEV - Browser code This property is now available in browser code for the Date and DateTime variables.
New in version 20
WEBDEV - Browser code This property is now available in browser code for the Date and DateTime variables.
WEBDEV - Browser code This property is now available in browser code for the Date and DateTime variables.
Versions 21 and later
Apple Watch This property is now available in Apple Watch mode.
Universal Windows 10 App This property is now available in Universal Windows 10 App mode.
New in version 21
Apple Watch This property is now available in Apple Watch mode.
Universal Windows 10 App This property is now available in Universal Windows 10 App mode.
Apple Watch This property is now available in Apple Watch mode.
Universal Windows 10 App This property is now available in Universal Windows 10 App mode.
Example
// Operations on a Date variable
StartDate is Date = "20011212"
// Add 1 month to the date
StartDate..Month++
// Modify the month
StartDate..Month = 5
// Operations on an item
Work.StartDate = "20011212"
// Add 1 month to the date
Work.StartDate..Month++
// Modify the month
Work.StartDate..Month = 5
Syntax

Finding out 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 Date or DateTime variable to use.

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

<Date>..Month = <New Month>
<Date>: Date or DateTime
Name of the Date or DateTime variable to use.
<New Month>: Integer or character string
New month expressed in numbers (included between 1 and 12). Replaces the month in the specified date.
WEBDEV - Browser code Not available in browser code

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

<Result> = <File Name>.<Item Name>..Month
<Result>: Integer
Month on 2 digits.
<File Name>: Character string (with or without quotes)
Name of data file used. This name was defined in the data model editor or by the File Description type.
<Item Name>: Character string (with or without quotes)
Name of item used. This name was defined in the data model editor or by the Item Description type.
WEBDEV - Browser code Not available in browser code

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

<File Name>.<Item Name>..Month = <New Month>
<File Name>: Character string (with or without quotes)
Name of data file used. This name was defined in the data model editor or by the File Description type.
<Item Name>: Character string (with or without quotes)
Name of item used. This name was defined in the data model editor or by 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

Range of dates

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

Managing the months and years

Case 1: Direct assignment
During a direct assignment (for example, MyWork.MyDate..Month = n), the month must be included between 01 and 12. A WLanguage error occurs if an invalid month is specified.
The notation MyWork.MyDate..Month = MyWork.MyDate..Month + 5 may generate an error at run time. For example, the following code lines trigger an error:
// Code triggering the error
MyDate is Date = "20041126" // 11/26/2004
MyDate..Month = MyDate..Month + 2
// Triggers a WLanguage error because the month is equal to 13

// Correct code
MyDate is Date = "20041126" // 11/26/2004
MyDate..Month += 2

// Code triggering the error
MyDate is Date = "20041126" // 11/26/2004
MyDate1 is Date
MyDate1..Month = MyDate..Month + 2
// Triggers a WLanguage error because the month is equal to 13

// Correct code
MyDate1 = MyDate   // 11/26/2004
MyDate1..Month += 2
Case 2: Operations on the 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:
StartDate is Date = "20041226"   // 12/26/2004
// Add 5 months to the date
StartDate..Month += 5        // StartDate is "20050526"

Operators available for the months

The following arithmetic operators can be used by ..Month:
  • ++ and --
  • += and - =
StartDate is Date = "20041126"  
StartDate..Month++               // Add 1 month to the date
StartDate..Month += 5       // Add 5 months to the date
StartDate..Month -= 5        // Subtract 5 months from the date

Calculating the last day of the month

To find out the last day of a month, all you have to do is assign 31 to ..Day. The last day will be automatically calculated according to the specified month.
StartDate is Date = "20041126"  
StartDate..Day = 31    
// November does not have 31 days
// The day is automatically replaced by 30

Calculating a payment date at 90 days (end of month)

..Day is used to calculate a payment date at 90 days (end of month).
MyDate is Date = "20041126"  
MyDate..Day += 90    
MyDate..Day = 31

Calculating the end of a floating month

A floating month corresponds to a one-month period from a given date. ..Month and ..Day are used to calculate the end date of a floating month.
StartDate is Date = "20041126"  
EndDate is Date = StartDate
EndDate..Month++    
EndDate..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