ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / Date and time functions
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Returns or modifies the system date (current date defined on the current computer).
Remarks:
  • WEBDEV - Server code The system date corresponds to the current date defined on the server.
  • This function is equivalent to Today.
Example
Res = DateSys()   // Res = "20011225"
Res = DateToString(DateSys()) // Res = "25/12/2001"
Année = Left(DateSys(), 4)
// Année retourne l'année en cours (par exemple 2001)
WINDEVWEBDEV - Server codeReports and QueriesWindowsUser code (UMC)AjaxStored procedures
// Change la date système et affiche la nouvelle date
DateSys("20020101")
Info(DateSys())
WINDEVWEBDEV - Server codeReports and QueriesWindowsLinuxAndroidAndroid Widget JavaUser code (UMC)PHPAjaxStored procedures
DateAujourdhui is Date = DateSys()
SAI_Date = DateToDayInAlpha(DateAujourdhui) + " " + DateAujourdhui.Jour + ...
	" " + DateToMonthInAlpha(DateAujourdhui) + " à " + ...
	TimeToString(TimeSys(), "HH:MM:SS")
// Le champ SAI_Date contient par exemple: Lundi 13 Août à 14:44:17
Syntax

Getting the system date Hide the details

<Result> = DateSys()
<Result>: Character string or Date variable
System date in YYYYMMDD format (YYYY corresponds to the year, MM to the month and DD to the day).
WINDEVWEBDEV - Server codeReports and QueriesWindowsUser code (UMC)Ajax

Change system date Hide the details

DateSys(<New date>)
<New date>: Character string, Date or DateTime variable
New system date. This date can correspond to:
  • a character string in YYYYMMDD format (YYYY corresponds to the year, MM to the month and DD to the day).
  • a character string in YYYYMMDDHHmmSSCC format (YYYY corresponds to the year, MM to the month, DD to the day, HH to hours, mm to minutes, SS to seconds and CC to hundredths of a second (use CCC for thousandths of a second)). In this case, only the date is taken into account.
  • a Date variable.
  • a DateTime variable. In this case, only the date is taken into account.
Remarks
  • To get the system date in a format other than YYYYMMDD, the string must be formatted using the DateToString, Right, Left functions or the date properties. The YYYYMMDD format was chosen because it allows you to check the order of dates. This would not be possible with a date in YYYYDDMM or DDMMYYYY format, for example.
  • On all current systems, the year of the system date can be between 1920 and 2120.
  • Attention: To change the system date, you must have administrator rights on the current workstation..
  • WEBDEV - Browser codeLinuxAndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystJavaPHP In this version, DateSys can only be used to return the system date (of the current computer or the computer where the browser is running).
  • AndroidAndroid Widget iPhone/iPad In simulation mode, the date of the PC is used. At runtime, the date of the mobile device is used.
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
Business / UI classification: Neutral code
Component: wd300std.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
WinDev for a Windows application: beware of user privileges!
When trying to set the computer's clock to a certain date / time, the functions DateSys("20151231") or TimeSys("18:00:00") will not return an error code if the computer's clock is not set (mostly because of missing admin rights). If you wish to be able to act on a returned error then use the API SetSystemTime.
Jimbo
21 May 2015

Last update: 09/19/2024

Send a report | Local help