PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Declaration and initialization
  • Properties that can be used on the DateTime variables
  • Interval of data
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
The DateTime type is used to easily handle a date and a time. The DateTime type can be used to perform calculations (subtraction, addition, ...) on the dates, times and durations. See Operations that can be performed on the DateTime type for more details.
Notes:
  • Several properties can be used with the DateTime type, to retrieve the date or the time, a part of the date or a part of the time.
  • See Declaring a variable for more details.
Versions 16 and later
Universal Windows 10 App This type of variable is now available for the Windows Phone applications.
New in version 16
Universal Windows 10 App This type of variable is now available for the Windows Phone applications.
Universal Windows 10 App This type of variable is now available for the Windows Phone applications.
Versions 17 and later
iPhone/iPad This type of variable is now available for iPhone/iPad applications.
New in version 17
iPhone/iPad This type of variable is now available for iPhone/iPad applications.
iPhone/iPad This type of variable is now available for iPhone/iPad applications.
Versions 18 and later
Universal Windows 10 App This type of variable is now available in Windows Store apps mode.
Android Widget This type of variable is now available in Android Widget mode.
New in version 18
Universal Windows 10 App This type of variable is now available in Windows Store apps mode.
Android Widget This type of variable is now available in Android Widget mode.
Universal Windows 10 App This type of variable is now available in Windows Store apps mode.
Android Widget This type of variable is now available in Android Widget mode.
Versions 20 and later
WEBDEV - Browser code This type of variable is now available in browser code.
New in version 20
WEBDEV - Browser code This type of variable is now available in browser code.
WEBDEV - Browser code This type of variable is now available in browser code.
Versions 21 and later
Universal Windows 10 App This type of variable is now available in Universal Windows 10 App mode.
Apple Watch This type of variable is now available in Apple Watch mode.
New in version 21
Universal Windows 10 App This type of variable is now available in Universal Windows 10 App mode.
Apple Watch This type of variable is now available in Apple Watch mode.
Universal Windows 10 App This type of variable is now available in Universal Windows 10 App mode.
Apple Watch This type of variable is now available in Apple Watch mode.
Example
StartDate is DateTime = "200112311524"     // 31/12/2001 at 15:24
Remarks

Declaration and initialization

  • A DateTime variable can be initialized with a value of the following type:
    • Date: the hours and the minutes will be initialized to 0.
    • DateTime
    • Character string, in the following format
      • YYYYMMDD
      • YYYYMMDDHH
      • YYYYMMDDHHMM
      • YYYYMMDDHHMMSS
      • YYYYMMDDHHMMSSCC
      • YYYYMMDDHHMMSSLLL
        (YYYY: year, MM: month, DD: Day, HH: hour, MM: minutes, SS: seconds, CC: hundredths of a second, LLL: Thousandths of a second)
  • By default, a DateTime variable is initialized with today's date (system date) and with the system time. To define the default value assigned to the Date, Time and DateTime variables, use DateTimeByDefault.
Versions 19 and later
Note: You also have the ability to initialize a DateTime variable with the system date and time by using Now.
New in version 19
Note: You also have the ability to initialize a DateTime variable with the system date and time by using Now.
Note: You also have the ability to initialize a DateTime variable with the system date and time by using Now.

Properties that can be used on the DateTime variables

YearReturns or modifies the year of the specified date (in integer format).
TimeReturns or modifies the hour (in integer format).
DayReturns or modifies the day of the specified date (in integer format).
MillisecondReturns or modifies the number of milliseconds (in integer format).
MinuteReturns or modifies the number of minutes (in integer format).
MonthReturns or modifies the month of the specified date (in integer format).
DateReturns or modifies the date of the DateTime variable (in date format).
TimeReturns or modifies the time of the DateTime variable (in time format).
SecondReturns or modifies the number of seconds (in integer format).
StartDate is DateTime = "200112011530"
// Adds 5 years to the date
StartDate..Year += 5
// Modifies the month
StartDate..Month = 5
// Displays the date
Info("Date " + StartDate..Date)
// Displays the time
Info("Time " + StartDate..Time)

Interval of data

The DateTime type is used to manage data included between 01/01/0001 at 00:00 and 12/31/9999 at 23:59.
Related Examples:
Calculations on durations Unit examples (WINDEV): Calculations on durations
[ + ] Calculations on dates and times with the WLanguage functions:
- Calculate the duration between two moments (dates and times)
- Calculate a sum of durations
- Calculate an average of durations
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment