例如:1.某天加上(或减去)一个日期类型的值.
2.两个日期相加减,得到中间相差的天数.
3.两个日期相加减,得到相差的时间数.
等等.
谢谢!
5 个解决方案
#1
DateDiff()
#2
本示例使用 DateDiff 函数显示给定日期和今天的间隔天数。
Dim FirstDate, Msg As String ' Declare variables.
Dim SecondDate As Date
FirstDate = InputBox("Enter a date")
SecondDate = CDate(FirstDate)
Msg = "Days from today: " & DateDiff(DateInterval.Day, Now, SecondDate)
MsgBox (Msg)
Dim FirstDate, Msg As String ' Declare variables.
Dim SecondDate As Date
FirstDate = InputBox("Enter a date")
SecondDate = CDate(FirstDate)
Msg = "Days from today: " & DateDiff(DateInterval.Day, Now, SecondDate)
MsgBox (Msg)
#3
Dim dtStart As DateTime=#1/6/2004 11:59:59 PM#
Dim dtEnd As DateTime=#11/6/2003#
相加后的日期=dateAdd(DateInterval.Day,10,dtStart)
相差天数=datediff(DateInterval.Day,dtEnd,dtStart)
相差时间=datediff(DateInterval.Second,dtEnd,dtStart)(秒)
Dim dtEnd As DateTime=#11/6/2003#
相加后的日期=dateAdd(DateInterval.Day,10,dtStart)
相差天数=datediff(DateInterval.Day,dtEnd,dtStart)
相差时间=datediff(DateInterval.Second,dtEnd,dtStart)(秒)
#4
实例,今天的日期减6天:
Dim timeSpan As New TimeSpan(6, 0, 0, 0)
dim newDate as new datetime
newDate=Now.Date.Subtract(timeSpan)
Dim timeSpan As New TimeSpan(6, 0, 0, 0)
dim newDate as new datetime
newDate=Now.Date.Subtract(timeSpan)
#5
http://www.webasp.net/tech/article_show.asp?id=3619&fieldby=&keyword=
在这里面基本上所有的日期函数都有
在这里面基本上所有的日期函数都有
#1
DateDiff()
#2
本示例使用 DateDiff 函数显示给定日期和今天的间隔天数。
Dim FirstDate, Msg As String ' Declare variables.
Dim SecondDate As Date
FirstDate = InputBox("Enter a date")
SecondDate = CDate(FirstDate)
Msg = "Days from today: " & DateDiff(DateInterval.Day, Now, SecondDate)
MsgBox (Msg)
Dim FirstDate, Msg As String ' Declare variables.
Dim SecondDate As Date
FirstDate = InputBox("Enter a date")
SecondDate = CDate(FirstDate)
Msg = "Days from today: " & DateDiff(DateInterval.Day, Now, SecondDate)
MsgBox (Msg)
#3
Dim dtStart As DateTime=#1/6/2004 11:59:59 PM#
Dim dtEnd As DateTime=#11/6/2003#
相加后的日期=dateAdd(DateInterval.Day,10,dtStart)
相差天数=datediff(DateInterval.Day,dtEnd,dtStart)
相差时间=datediff(DateInterval.Second,dtEnd,dtStart)(秒)
Dim dtEnd As DateTime=#11/6/2003#
相加后的日期=dateAdd(DateInterval.Day,10,dtStart)
相差天数=datediff(DateInterval.Day,dtEnd,dtStart)
相差时间=datediff(DateInterval.Second,dtEnd,dtStart)(秒)
#4
实例,今天的日期减6天:
Dim timeSpan As New TimeSpan(6, 0, 0, 0)
dim newDate as new datetime
newDate=Now.Date.Subtract(timeSpan)
Dim timeSpan As New TimeSpan(6, 0, 0, 0)
dim newDate as new datetime
newDate=Now.Date.Subtract(timeSpan)
#5
http://www.webasp.net/tech/article_show.asp?id=3619&fieldby=&keyword=
在这里面基本上所有的日期函数都有
在这里面基本上所有的日期函数都有