# DATEDIFF - THE TRUTH

P

#### POL

Function STJ(ndt As Date, kdt As Date, vid As Integer) As String
Dim ndden, ndmes, ndgod, kdden, kdmes, kdgod, dni, mes, god As Integer
' vid Ã±Ã¥ Ã¢Ã Ã¤Ã¨ Ã¯Ã°Ã¨ Ã¨Ã§Ã·Ã¨Ã±Ã«Ã¿Ã¢Ã Ã­Ã¥Ã²Ã® - Ã².Ã¥. Ã ÃªÃ® Ã±Ã¥ Ã­Ã Ã¯Ã¨Ã¸Ã¥ ÃªÃ Ã²Ã® Ã¢ Ã²Ã°. ÃªÃ­. \1\ Ã±Ã¥
Ã¨Ã§Ã·. Ã¤Ã® Ã¯Ã°Ã¥Ã¤. Ã¤Ã¥Ã­
If ndt >= kdt Then
MsgBox ("ÃƒÃ°Ã¥Ã¸Ã­Ã® Ã§Ã Ã¤Ã Ã¤Ã¥Ã­Ã¨ Ã¤Ã Ã²Ã¨")
Exit Function
End If
Dim ndtt, kdtt As String
ndtt = Format(ndt, "mmddyyyy")
kdtt = Format(kdt, "mmddyyyy")
'MsgBox ndtt
'MsgBox kdtt
ndmes = Val(Left(ndtt, 2))
kdmes = Val(Left(kdtt, 2))
ndden = Val(Mid(ndtt, 3, 2))
kdden = Val(Mid(kdtt, 3, 2))
ndgod = Val(Right(ndtt, 4))
kdgod = Val(Right(kdtt, 4))
If ndgod = kdgod Then
god = 0
If kdden >= ndden Then
mes = kdmes - ndmes
dni = kdden - ndden
Else
mes = kdmes - ndmes - 1
dni = (dnimes(ndmes, ndgod) - ndden + vid) + kdden - vid
End If
STJ = Format(god, "00") + Format(mes, "00") + Format(dni, "00")
Exit Function
Else
If kdden >= ndden Then
dni = kdden - ndden
If kdmes >= ndmes Then
god = kdgod - ndgod
mes = kdmes - ndmes
Else
god = kdgod - ndgod - 1
mes = kdmes + (12 - ndmes)
If mes = 12 Then
god = god + 1
mes = 0
End If
End If
Else 'Ã­Ã Ã·Ã Ã«Ã¥Ã­ Ã¤Ã¥Ã­ Ã¥ Ã¯Ã®-Ã£Ã®Ã«Ã¿Ã¬ Ã®Ã² ÃªÃ°. Ã¤Ã¥Ã­
dni = (dnimes(ndmes, ndgod) - ndden + vid) + kdden - vid
If kdmes > ndmes Then
mes = kdmes - ndmes - 1
god = kdgod - ndgod
Else
god = kdgod - ndgod - 1
mes = kdmes + (12 - ndmes)
If mes = 12 Then
god = god + 1
mes = 0
End If
End If
End If
STJ = Format(god, "00") + Format(mes, "00") + Format(dni, "00")
Exit Function
End If
STJ = Format(god, "00") + Format(mes, "00") + Format(dni, "00")
End Function

J

#### John Vinson

Function STJ(ndt As Date, kdt As Date, vid As Integer) As String
Dim ndden, ndmes, ndgod, kdden, kdmes, kdgod, dni, mes, god As Integer
' vid ñå âàäè ïðè èç÷èñëÿâàíåòî - ò.å. àêî ñå íàïèøå êàòî â òð. êí. \1\ ñå
èç÷. äî ïðåä. äåí
If ndt >= kdt Then
POL, is this a suggestion, a question, an answer, or what? I have no
idea what you're posting.

John W. Vinson[MVP]