Official Content

Returns the seconds elapsed between two DateTime data type values.

Syntax

DateTime-expression1.Difference(DateTime-expression2)

Where:

DateTime-expression1
    
Is an expression that returns a value based on the DateTime data type.

DateTime-expression2 
      Is an expression that returns a value based on the DateTime data type. This is the value subtracted from DateTime-expression1.

Type Returned:
Numeric

Scope

Data Types: DateTime
Generators: .NET, .NET Framework, Java, Android, Apple

Description

Returns the amount of seconds elapsed between the two DateTime values received as parameters (DateTime-expression1 DateTime-expression2). If DateTime-expression2 is greater than DateTime-expression1, a negative value is returned.

Notes:

  • If the arguments support Milliseconds, the resulting numeric value will contain decimals that represent the milliseconds.
  • If some parameters have null value, then the return value will be zero.


Samples

&Nbr = &DateTime1.Difference(&DateTime2)     

Being &DateTime1= 09/13/22 09/07/22 12:00:30 and &DateTime2= 09/13/22 09/07/22 12:00:00 ==>> &Nbr = 30
Being &DateTime1= 09/13/22 09/07/22 12:00:00 and &DateTime2= 09/13/22 09/07/22 12:00:50 ==>> &Nbr = -50

&Nbr=&DateTime1.Difference(&DateTime2.AddMinutes(30))
&Nbr=&DateTime1.AddDays(5).Difference(&DateTime2.AddMinutes(30))

See Also

TDiff function
AddSeconds method



Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant