Official Content

Adds hours to a DateTime attribute or variable.

Syntax

Date | DateTime.AddHours(Numeric-expression)

Where:

Date | DateTime
     
Is an attribute or variable based on the Date/DateTime data type, to which the method will add a certain number of hours.

Numeric-expression
     Is a Numeric expression that indicates the number of hours to be added to the Date | DateTime.

Type returned:
DateTime

Scope

Data Types: DateTime
Generators: .NET, .NET Framework, Java, RPG, Cobol, Ruby (up to GeneXus X Evolution 3), Visual FoxPro (up to GeneXus X Evolution 3)

Description

This method adds the specified number of hours to a given date and time, returning a DateTime value with the additional hours (the result will be always based on the DateTime data type).

It is useful for scenarios where you need to manipulate date and time values by adding or subtracting hours.

Samples

&AppointmentDateTime = &AppointmentDateTime.AddHours(1)               //Adds 1 hours to &AppointmentDateTime variable
&AppointmentDateTime = &AppointmentDateTime.AddHours(&HoursNmbr + 1)  //&HoursNmbr is a variable received as a parameter using the Parm rule.

See Also

AddMinutes method
AddDays method

   

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