CDate功能使用不同的区域设置 [英] CDate function using different locales

查看:214
本文介绍了CDate功能使用不同的区域设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用QTP(因此是VBScript),我似乎对CDate功能有问题。

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.

现在我问的是,如果这个函数有任何已知的问题或任何其他相关的问题,如FormatDateTime之间

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.

有人知道吗?

提前感谢

推荐答案

错误指定了问题。 todateObject.GetROProperty(value)包含一个值 CDate 不被视为日期。

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

您将需要首先确定是什么由 todateObject.GetROProperty(value)返回,然后确保它可以转换为日期。

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.

您可能需要考虑使用 DateSerial 创建日期,而不是CDate可避免文化差异引起的问题。如果是这种情况,根据您的情况,您可能需要为日,月和年提供单独的字段,以确保订单始终是正确的。

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.

这篇关于CDate功能使用不同的区域设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆