PDA

View Full Version : world war 2



lior03
01-29-2007, 05:26 AM
helo
i need to create a udf that will calculate how many days passed between
09/01/1939 and a given date

Function ww2(d As Date) As Integer
If d < 1 / 9 / 1939 Or d > 8 / 9 / 1945 Then
d = 0
Else
ww2 = d - DateSerial(1939 / 9 / 1)
End If
End Function

please help

stanl
01-29-2007, 06:02 AM
maybe, use datediff



Function TestDates ( pDate1 as Date) as Long
pDate2 = '09/01/1939'
TestDates = DateDiff("d", pDate1, pDate2)
End Function


Stan

mdmackillop
01-29-2007, 06:03 AM
Function ww2(d As Date) As Integer
If d < 16688 and d > 14489 Then
ww2 = d - 14489
Else
ww2 = 0
End If
End Function

Bob Phillips
01-29-2007, 06:09 AM
Why?

a simple subtractiuon will do it

=A1-"1939-09-01"