Skip to content

DATEVALUE


从字符串返回日期序列

语法

declare function DateValue ( byref date_string as string ) as long

用法

#include "vbcompat.bi"
result = DateValue( date_string )

参数

date_string

要转换为日期序列的字符串

返回值

从日期字符串返回日期序列

说明

日期字符串必须采用操作系统区域设置中设置的格式。

仅当区域设置指定了与 QB 相同的短日期格式(mm-dd-yyyy)时,DateValue( Date() ) 才能正常工作。考虑使用 Fix(Now()) 表达式中的 Now 函数来获取当前日期作为日期序列。

除非包含 vbcompat.bidatetime.bi,否则编译器不会识别此函数。

示例

start GeSHi

vb
#include "vbcompat.bi"

Dim As Long v1, v2
Dim As String  s1, s2

Print "Enter first date: ";
Line Input s1

If IsDate( s1 ) = 0 Then
  Print "not a date"
  End
End If

Print "Enter second date: ";
Line Input s2

If IsDate( s2 ) = 0 Then
  Print "not a date"
  End
End If

'' convert the strings to date serials
v1 = DateValue( s1 )
v2 = DateValue( s2 )

Print "Number of days between dates is " & Abs( v2 - v1 )

end GeSHi

与 QB 的差异

  • QB 中不存在。此函数出现在 PDS 和 VBDOS 中。

另请参阅

返回 目录

基于 FreeBASIC 官方文档翻译 如有侵权请联系我们删除
FreeBASIC 是开源项目,与微软公司无隶属关系