LeaderBoard

str2Datetime Function

Generates a utcdatetime value from the specified string of date and time information.

utcdatetime str2datetime( str text, int sequence )

Parameters













ParameterDescription
textThe string to convert into a utcdatetime value.
sequenceA three digit number that describes the sequence of the date components in the text parameter.

 

Return Value





A utcdatetime value that represents the specified date and time.

If the value of the sequence parameter is invalid (such as -1, or 3, or 9876), the regional settings are used to interpret the text parameter.

If the input parameters describe an invalid date/time, then an empty string is returned.

Remarks





The syntax requirements for the date portion of the text parameter are flexible. The variety of valid formats is the same as in the date2str function.

Each of the following calls to str2datetime is valid and produce the same output:

utc3 = str2datetime( "1985/02/25 23:04:59" ,321 );
utc3 = str2datetime( "Feb-1985-25 11:04:59 pm" ,231 );
utc3 = str2datetime( "2 25 1985 11:04:59 pm" ,123 );

Each component of the date time is represented by a digit in the sequence parameter:



  • 1 – day



  • 2 – month



  • 3 – year


For example, YMD is 321. All valid values contain each of these three digits exactly one time. If the value of the sequence parameter is invalid, the regional settings are used to interpret the input text parameter.

If the input parameters describe an invalid date and time, an empty string is returned.

Example




static void JobTestStr2datetime( Args _args )
{
utcdatetime utc3;
str sTemp;
;
utc3 = str2datetime( "1985/02/25 23:04:59" ,321 );
sTemp = datetime2str( utc3 );
print( "sTemp == " + sTemp );
pause;
}

No comments:

Post a Comment

Your comment will be appreciated.