1 1 1 1 1 1 1 1 1 1 Rating 0.00 (0 Votes)

Problemstellung:

Für 32Bit und 64Bit Office Versionen

Wie kann ich den letzten Tag des Halbjahres, ausgehend von einem beliebigen Datum, ermitteln? 

Public Function LastDayHalfYear(dateDatum As Date)
'*******************************************
'Name:      LastDayHalfYear (Function)
'Purpose:   Ermittelt den letzten Tag des aktuellen Halbjahres ausgehend von dateDatum
'Author:    Thomas Keßler
'Date:      Februar 12, 2004, 11:45:00
'Inputs:    dateDatum= Datum ab dem gerechnet werden soll
'Output:
'*******************************************
    Dim wrkDate As Variant
    Dim intHbj As Integer
    Dim intMonth As Integer
    Dim intYear As Integer
    intYear = Year(dateDatum)
    intHbj = Int((Month(dateDatum) - 1) / 6)
    intMonth = (intHbj * 6) + 7
    wrkDate = DateSerial(intYear, intMonth, 1)
    LastDayHalfYear = DateAdd("d", -1, wrkDate)
End Function

Aufruf:

Dim x As Variant
x =LastDayHalfYear(#02.04.2004#)

Das Ergebniswäre x = 30.06.2004

 

Ähnliche Artikel