ini code untuk mencari selisih tahun, bulan dan hari. tapi jangan lupa masukkan datefrom n dateto

" terdiri dari 3 function u taruh aja di module oke... selamat mencoba.. jika ada pertanyaan e-mail gwe aja.


Public Function ExactAgeYear(datFrom As Date, _
                         Optional datTo As Variant) As String

Dim iYYYY As Integer
Dim iMM As Integer
Dim iDD As Integer
Dim sAns  As String
 
  If IsMissing(datTo) Then ' variant used in parm list so IsMissnig will work
    datTo = Date
  End If
 
  iYYYY = Year(datFrom)
  iMM = Month(datFrom)
  iDD = Day(datFrom)
  iYYYY = Year(datTo) - iYYYY
  iMM = Month(datTo) - iMM
  iDD = Day(datTo) - iDD
 
  If Sgn(iDD) = -1 Then  'this causes a miscalculation if the
    iDD = 30 - Abs(iDD)  'month prior the ToDate does not contain 30 days
    iMM = iMM - 1        'and the statment is true
  End If
 
  If Sgn(iMM) = -1 Then
    iMM = 12 - Abs(iMM)
    iYYYY = iYYYY - 1
  End If
 
  ExactAgeYear = iYYYY
End Function

Public Function ExactAgeMonth(datFrom As Date, _
                         Optional datTo As Variant) As String

Dim iYYYY As Integer
Dim iMM As Integer
Dim iDD As Integer
Dim sAns  As String
 
  If IsMissing(datTo) Then ' variant used in parm list so IsMissnig will work
    datTo = Date
  End If
 
  iYYYY = Year(datFrom)
  iMM = Month(datFrom)
  iDD = Day(datFrom)
  iYYYY = Year(datTo) - iYYYY
  iMM = Month(datTo) - iMM
  iDD = Day(datTo) - iDD
 
  If Sgn(iDD) = -1 Then  'this causes a miscalculation if the
    iDD = 30 - Abs(iDD)  'month prior the ToDate does not contain 30 days
    iMM = iMM - 1        'and the statment is true
  End If
 
  If Sgn(iMM) = -1 Then
    iMM = 12 - Abs(iMM)
    iYYYY = iYYYY - 1
  End If
 
  ExactAgeMonth = iMM
End Function

Public Function ExactAgeDay(datFrom As Date, _
                         Optional datTo As Variant) As String

Dim iYYYY As Integer
Dim iMM As Integer
Dim iDD As Integer
Dim sAns  As String
 
  If IsMissing(datTo) Then ' variant used in parm list so IsMissnig will work
    datTo = Date
  End If
 
  iYYYY = Year(datFrom)
  iMM = Month(datFrom)
  iDD = Day(datFrom)
  iYYYY = Year(datTo) - iYYYY
  iMM = Month(datTo) - iMM
  iDD = Day(datTo) - iDD
 
  If Sgn(iDD) = -1 Then  'this causes a miscalculation if the
    iDD = 30 - Abs(iDD)  'month prior the ToDate does not contain 30 days
    iMM = iMM - 1        'and the statment is true
  End If
 
  If Sgn(iMM) = -1 Then
    iMM = 12 - Abs(iMM)
    iYYYY = iYYYY - 1
  End If
 
  ExactAgeDay = iDD
End Function


On 12/11/05, Darsana <[EMAIL PROTECTED]> wrote:
Netters,
 
Bila sekarang tanggal 30 Desember 2005, kita mau mencari tanggal berapa 2 bulan lagi ? kan nga mungkin tgl 30 Peb 2006. nah apakah ada fungsi nyari tanggal berdasarjkan selisih bulan ? atau menggunakan logika sendiri ya ?
 
thanks,
darsana


Untuk keluar dari millis ini, kirim email kosong ke:
[EMAIL PROTECTED]





YAHOO! GROUPS LINKS






Untuk keluar dari millis ini, kirim email kosong ke:
[EMAIL PROTECTED]





SPONSORED LINKS
Programmer Indonesia Basic programming language
Computer programming languages Programming languages Java programming language


YAHOO! GROUPS LINKS




Kirim email ke