Date
当与1个或无参数一起使用时...
Result = Date ( Expression )
返回日期和时间表达式的日期部分。如果省略表达式,则返回今天的日期。
使用当前本地化,即返回当前时区的日期部分。
换句话说,该函数将移至过去的当前当地时间的0:00的日期。
示例
Print Now; " -> "; Date(Now)
05/16/2002 15:10:59 -> 05/16/2002 00:00:00
Warning:
As can be seen in the previous example using Date() directly with
PRINT this way (and in other instances)
does not actually omit the time part but shows it as 00:00:00.
This is because using the Date() command always returns a
Date datatype. The Date datatype returned
does have a time but it is nullified using Date() this way hence the 00:00:00.
Assigning the Date() result to a
String first will solve the issue.
Or use
Split. (see the following example)
同样的例子从两个方面适当地省略了时间部分。。。
Dim sDate As String = Date(Now) ' Put the localized Date() result to a String datatype (time is omitted)
Print Now ' Print non localized date.
Print sDate ' Print as String type not Date type.
Print Split(Date(Now), " ")[0] ' Or Split the localized Date() result at the space.
09/02/2024 12:39:23
02/09/2024
02/09/2024
Date (2)
日期 = Date ( 年 , 月 , 日 [ , 时 , 分 , 秒 ] )
生成由给定的参数描述的本地日期和时间。
日期部分采用当地时间。
示例
Print Date(1972, 09, 06, 1, 5, 17)
Print Date(1972, 09, 06, 1, 5, 17)
Print CFloat(Date(1972, 09, 06, 1, 5, 17))
06.09.1972 01:05:17
2473671,04533565
Date (3)
Print Date()
返回当前日期。
参见