Версия для печати темы

Нажмите сюда для просмотра этой темы в обычном формате

Форум программистов _ Библиотеки скриптов _ Количество дней между датами

Автор: root 12:04:2007, 03:40

Function  Betwindate(Byval d1 As Integer , Byval  m1 As Integer , Byval y1 As Integer , Byval d2 As Integer , Byval m2 As Integer, Byval y2 As Integer ) As Long  
    Dim Result As Long
    Dim n1 As Long
    Dim n2 As Long
    
    If m1>2 Then
        m1 = m1+1
    Else
        m1 = m1+13
        y1 = y1-1
    End If
    n1 = 36525*y1\100+306*m1\10+d1
    If m2>2 Then
        m2 = m2+1
    Else
        m2 = m2+13
        y2 = y2-1
    End If
    n2 = 36525*y2\100+306*m2\10+d2
    Result = n2-n1
    
    Betwindate= Result
    
    
End Function

Автор: Morpheus 1:06:2007, 11:33

хм.... захожу в справку к собаке @Adjust
и виже такою себе штуку -

Tip

Цитата
To find the difference between two dates, subtract them. The result is returned in seconds. To adjust the result to days, divide the result by 86,400 - which is the number of seconds in a day. For example, if you have two date fields, date1, which contains [07/01/01] and date2, which contains [07/05/01], use the following formula to return the number of days between the two dates:
(date2-date1)/86400
This code returns 4.


Вапрос: чем Вам нее подходит вышеприведенный способ? wink.gif

Автор: Domino6 20:06:2007, 12:05

DateTimeDif=cdate(cdbl(DateTimeEnd)-cdbl(DateTimeBegin))


Сразу вернёт разницу в датовом формате 02.03.1980 12:23:02

т.е. разница составила

0 лет
3 месяца
2 дня
12 часов
23 минут
2 секунды

Форум Invision Power Board (http://nulled.ws)
© Invision Power Services (http://nulled.ws)