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 ersten Tag des Halbjahres, ausgehend von einem beliebigen Datum, ermitteln?

Public Function FirstDayHalfYear(dateDatum As Date)
'*******************************************
'Name:      FirstDayHalfYear (Function)
'Purpose:   Ermittelt den ersten 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 intHbj As Integer
    Dim intMonth As Integer
    Dim intYear As Integer
    intYear = Year(dateDatum)
    intHbj = Int((Month(dateDatum) - 1) / 6)
    intMonth = (intHbj * 6) + 1
    FirstDayHalfYear = DateSerial(intYear, intMonth, 1)
End Function

Aufruf:

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

Das Ergebniswäre x = 01.01.2004

 

Ähnliche Artikel