Overture Search the Web.
Type it and go!
 
 
 
 

4Test Tips - DATE and TIME Data

DATETIME Variables can be set with string data

Within functions, you may assign a string in ISO standard date format to a DATETIME variable. It will be implicitly cast to DATETIME. If you are trying to set a global variable (outside of a function call) then you will need to explicitly cast it to DATETIME. Thus the assignment statements would look like:

DATETIME dtAnytime = [DATETIME] "2001-04-01 12:34:00"

MyFunction ( STRING sInput)
    DATETIME dtThisTime = "2001-04-02 12:34:00"

 

Casting to TIME can change DATE portion of DATETIME variables

If you are attempting to get the time portion of a DATETIME variable by casting the variable to TIME, the date portion of the source variable will be set to the present date. More specifically, for the statement below:

    tThen = [TIME] dtThen

both the tThen and the dtThen variables will be modified.  The surprise is that dtThen gets today's date.  Normal programming languages do not modify variables to the right of an assignment operator.  This behavior has been seen on 32-bit Windows QAP 4.6.2 and on Solaris 2.5 with QAP 4.0.

On 1999-03-11, Segue technical support said, "It may not be intuitive, but it's working as designed."  The documentation of the TIME data type says, "If you cast from a type DATETIME to a TIME, you lose the date information."  Many people may have thought it was only the TIME variable that lost the date information.  But the input DATETIME variable also loses it  because it is replaced with today's date!  (get test here)
Solution - Before performing the [TIME] cast operation, place the original value in a temporary variable to be cast.

    DATETIME dtTemp
    dtTemp = dtThen
    tThen = [TIME] dtTemp

 

 

Send questions or comments about this web site to: webmaster@TestMap.com
Copyright © 1998,2001 Charles B. Hedstrom