Skip to content

DateAdd


将日期偏移指定的时间间隔

语法

declare function DateAdd ( byref interval as const string, byval number as double, byval date_serial as double ) as double

用法

#include "vbcompat.bi"
result = DateAdd( interval, number, date_serial )

参数

interval

指示 number 的一个单位对应哪个时间段的字符串

number

要加到基准日期的时间间隔数量。该数字将四舍五入到最近的整数。

date_serial

基准日期

返回值

返回对应 date_serial 加上 numberinterval 后的日期序列

说明

interval 指定如下:

时间间隔
yyyy
q季度(三个月)
m
ww
d,w,y
h小时
n分钟
s

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

示例

start GeSHi

vb
#include "vbcompat.bi"

Const fmt = "ddddd ttttt"
Dim d As Double
d = Now()

Print "1 hour from now is ";
Print Format( DateAdd( "h", 1, d ), fmt )

Print "1 day from now is ";
Print Format( DateAdd( "d", 1, d ), fmt )

Print "1 week from now is ";
Print Format( DateAdd( "ww", 1, d ), fmt )

Print "1 month from now is ";
Print Format( DateAdd( "m", 1, d ), fmt )

end GeSHi

与 QB 的差异

  • QB 中不存在。此函数出现在 Visual Basic 中。

另请参阅

返回 目录

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