DateSetHour

See Also: Time and Date Functions

Purpose

The DateSetHour function returns a new DateTime value that is the original value, dtVar, with the hour component changed to iHour.

Return Type

DateTime or TimeSpan

 

We recommend using the newer, higher level DateSet function to set a date and the DateAddXXX (DateAddDay, DateAddHour, DateAddMillisecond, DateAddMinute, DateAddMonth, DateAddSecond, DateAddYear) functions to manipulate DateTimes/Dates and the DateGetXXX (DateGetDay, DateGetHour, DateGetMillisecond, DateGetMinute, DateGetMonth, DateGetSecond, DateGetYear) functions to retrieve DateTimes/Dates.

The DateSetXXX (DateSetDay, DateSetHour, DateSetMillisecond, DateSetMinute, DateSetMonth, DateSetSecond, DateSetYear) functions have the following limitations:

Syntax

DateSetHour( {dtVar}, {iHour} )

Where:

Example

Procedure testDateSetHour

    DateTime dtVar

 

    //Get the current local date and time

    Move (CurrentDateTime()) to dtVar

    Move (DateSetHour(dtVar, 9)) To dtVar 

 

    // This will print:

    // The Hour of 2/23/2005 9:12:37 AM is: 9

    Showln "The Hour of " dtVar " is: " (DateGetHour(dtVar))

End_Procedure

Notes