-
DateDiff
Count = DateDiff ( Date1 AS Date , Date2 AS Date , Period AS Integer ) AS Integer |
2つの日付間の期間数を返します。
- Date1は開始日です。
- Date2は終了日です。
- 期間は期間の種類です。年、月、日、週...
期間数が返されます。
期間は、次の定数のいずれかになります。
Constant |
Effect |
---|---|
gb.Second |
Returns the number of seconds. |
gb.Minute |
Returns the number of minutes. |
gb.Hour |
Returns the number of hours. |
gb.Day |
Returns the number of days. |
gb.Week |
Returns the number of weeks. |
gb.WeekDay |
Returns the number of week days (ignores Saturday and Sunday). |
gb.Month |
Returns the number of months. |
gb.Quarter |
Returns the number of quarters. |
gb.Year |
Returns the number of years. |
全期間のみが返されます。 結果は切り捨てられます。
Examples
Print DateDiff("01/02/2005 12:55:00", "01/01/2005", gb.Day)
-1
This example shows how DateDiff works internally.
Dim date1 As Date
Dim date2 As Date
Dim fDiff As Float
Dim iDiff As Integer
date1 = Date(1964, 02, 28, 0, 29, 0)
date2 = Date(1964, 03, 01, 0, 30, 0) ' one minute more than two days
fDiff = CFloat(date2) - CFloat(date1)
iDiff = Int(fDiff * 24)
Print "first : "; fdiff; " int:"; idiff; " DateDiff:"; DateDiff(date1, date2, gb.Hour)
date1 = Date(1964, 02, 28, 0, 30, 0)
date2 = Date(1964, 03, 01, 0, 29, 0) ' one minute less than two days
fDiff = CFloat(date2) - CFloat(date1)
iDiff = Int(fDiff * 24)
Print "second : "; fdiff; " int:"; idiff; " DateDiff:"; DateDiff(date1, date2, gb.Hour)
first : 2.000694444403 int:48 DateDiff:48
second : 1.999305555597 int:47 DateDiff:47
コメント
最新を表示する
NG表示方式
NGID一覧