Skip to content

DateSetMillisecond

See Also: Time and Date Functions

Purpose

The DateSetMillisecond function returns a new DateTime value that is the original value, dtVar, with the millisecond component changed to iMillisecond.

Return Type

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 functions (DateSetDay, DateSetHour, DateSetMillisecond, DateSetMinute, DateSetMonth, DateSetSecond, DateSetYear) have the following limitations:

  • Invalid values are allowed in all DateTime parts.
  • Negative values are wrapped.
  • Can be used with DateTime or TimeSpan without error.
  • Date return type may return an error (if out of its range).
  • Use IsDateValid (IsDateValid()), IsNullDateTime (IsNullDateTime()), and IsTimeSpanValid (IsTimeSpanValid()) to test if a variable is valid.

Syntax

DateSetMillisecond( {dtVar}, {iMillisecond} )

Where:

  • {dtVar} is a value of type DateTime.
  • {iMillisecond} is an integer value representing the new millisecond component of the DateTime.

Example

Procedure TestDateSetMillisecond
    DateTime dtVar
    // Get the current local date and time
    Move (CurrentDateTime()) To dtVar
    Move (DateSetMillisecond(dtVar, 250)) To dtVar
    // This will print:
    // The Millisecond of 2/23/2005 9:16:20.250 AM is: 250
    Showln "The Millisecond of " dtVar " is: " (DateGetMillisecond(dtVar))
End_Procedure