Search code examples
datevbscriptlocaleqtp

CDate function using different locales


I am using QTP (therefore VBScript) and I seem to have a problem with the CDate function.

When my colleague in Malaysia is using it there is not a problem. When I use it here in Spain I have the following error.

enter image description here

Now all I am asking is if there are any known issues with this function or any other related ones like FormatDateTime between different locales.

Anybody knows this?

Thanks in advance.


Solution

  • The error specifies the problem. todateObject.GetROProperty("value") contains a value that CDate does not recognize as a date.

    You will need to first determine what is being returned by todateObject.GetROProperty("value"), and then make sure it can be converted to a date.

    You may want to consider creating the date using DateSerial instead of CDate to avoid problems arising from cultural differences. If that is the case, depending on your circumstance you may need to provide separate fields for Day, Month, and Year to assure the order is always correct.