Results 1 to 5 of 5

Thread: Using DateAdd

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    9

    Question

    I'm working on a program that generates trigger dates from a date of hire using the DateAdd function. I can do it in an Access form but I need to use Visual Basic, which I'm not very familar with. Can anyone help?

  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    MSDN :
    DateAdd(interval, number, date)

    The interval argument has these settings:

    Setting Description
    yyyy = Year
    q = Quarter
    m = Month
    y = Day of year
    d = Day
    w = Weekday
    ww = Week
    h = Hour
    n = Minute
    s = Second
    Iain, thats with an i by the way!

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    9
    Great, but how would put that in a subroutine?

  4. #4
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658

    Code:
        Dim dt1 As Date, dt2 As Date
        Dim dtNew As Date
        Dim lDif As Long
        
        'set two date objects
        dt1 = "04/08/1979"
        dt2 = Now
        
        'find the number of months difference between the dates
        lDif = DateDiff("m", dt1, dt2)
        'add the difference to dt2, to create a new date
        dtNew = DateAdd("m", lDif, dt2)
    Iain, thats with an i by the way!

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    9
    That helps, but I'm still having trouble getting the hire date from the database. Could someone show me an example?

Posting Permissions

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



Click Here to Expand Forum to Full Width