Consulting

Results 1 to 4 of 4

Thread: world war 2

  1. #1
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location

    world war 2

    helo
    i need to create a udf that will calculate how many days passed between
    09/01/1939 and a given date
    [VBA]
    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
    [/VBA]
    please help
    moshe

  2. #2
    VBAX Master stanl's Avatar
    Joined
    Jan 2005
    Posts
    1,141
    Location
    maybe, use datediff

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

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [vba]Function ww2(d As Date) As Integer
    If d < 16688 and d > 14489 Then
    ww2 = d - 14489
    Else
    ww2 = 0
    End If
    End Function
    [/vba]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Why?

    a simple subtractiuon will do it

    =A1-"1939-09-01"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •