PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
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
DateDifference (Function)
In french: DateDifference
Calculates the number of days between two dates.
Versions 16 and later
Universal Windows 10 App This function is now available for Windows Phone applications.
New in version 16
Universal Windows 10 App This function is now available for Windows Phone applications.
Universal Windows 10 App This function is now available for Windows Phone applications.
Versions 18 and later
Universal Windows 10 App This function is now available in Windows Store apps mode.
New in version 18
Universal Windows 10 App This function is now available in Windows Store apps mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Example
// Calculates the number of days passed since 01/01/1998
nbDays is int
nbDays = DateDifference("19980101", Today())
// Displays the result
Info(nbDays + " days passed")
Syntax
<Result> = DateDifference(<Start date> , <End date>)
<Result>: Integer
Number of days passed between two dates. This number of days results from the operation:
<End date> - <Start date>

The number of days is negative if <Start date> is after <End date>.
<Start date>: Character string or Date variable
Start date for the calculation in YYYYMMDD format (YYYY corresponds to the year, MM to the month and DD to the day).
<End date>: Character string or Date variable
End date for the calculation in YYYYMMDD format (YYYY corresponds to the year, MM to the month and DD to the day).
Remarks
The validity of dates passed in parameter is checked. A message is displayed if the date is invalid. The validity of a date can be checked by DateValid.
This function cannot be used to calculate the number of days between dates before October 14 1582 (the switch from the Julian calendar to the Gregorian calendar will not be taken into account).
The storage format allows you to store dates from 01/01/0001 to 12/31/9999.
The calculations performed on dates by the WLanguage functions or by the WLanguage properties are accurate from January 1st 1583.
Related Examples:
Management of dates Unit examples (WINDEV): Management of dates
[ + ] Using the Date type of WLanguage and the functions for handling dates.
Component : wd240std.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Video DateDifference
https://youtu.be/zHZUkRk3q5w

// btn_calcula_diferenca_datas

EDT_DIAS_CALCULADO=DateDifference(EDT_DATA_INICIAL,EDT_DATA_FINAL)

amarildo
16 Sep. 2019
Video DateDiference
https://youtu.be/1cnd0XoKAdg

https://windevdesenvolvimento.blogspot.com/2019/01/dicas-1986-windev-data-25.html

amarildo
15 Jan. 2019
Exemplo Diferença Entre Datas
//Exemplo Diferença Entre Datas
//Calcula Diferença entre Datas
//Calculate difference between dates
//Calculer la différence entre les date

EDT_diferenca=DateDifference(EDT_data_inicial,EDT_data_Final)

//Blog com Video e Exemplo
http://windevdesenvolvimento.blogspot.com.br/2016/06/curso-windev-datas-006-datedifference_13.html
https://www.youtube.com/watch?v=6hvFqTFwhTY
De matos AMARILDO
13 Jun. 2016
Example
// Time passed since 01/01/1998 at 12:15
sTDatahoraAgenda is string = Middle(StringToDate(EDT_DataAgendamento)+StringToTime(Middle(EDT_DataAgendamento,12,5)),1,12) //"199801011215"
Diff is string
Diff = DateTimeDifference(sTDatahoraAgenda, DateSys() + TimeSys())
//Display the time passed
//Info("Time passed: " + CR + ...
//Left(Diff, 8) + "days" + CR + ...
//Middle(Diff, 9, 2) + "hours" + CR + ...
//Middle(Diff, 11, 2) + "minutes" + CR + ...
//Middle(Diff, 13, 2) + "seconds" + CR + ...
//Middle(Diff, 15, 2) + "hundredths of a second")

//Valida data
nSMinutos is int = Val(Middle(Diff, 11, 2))
IF CBOX_Agendamento..Value = True AND Middle(Diff, 11, 2) < 30
Info("A data e hora agendada tem que ser maior do que 30 minutos")
ok1 = False
ELSE
ok1 = True
END
adrianoboller
27 Nov. 2015