Subtract Two Years From Current Date

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ahd2008
    New Member
    • Nov 2008
    • 68

    Subtract Two Years From Current Date

    Hi everybody,

    I want to create a code that subtract two years from the current date and returns the data.

    For instance

    Current date= 05/05/2009
    Date before two years=current date-(2 years)
    Date before two years=MM/DD/YYYY

    Appreciate your cooperation
  • JustJim
    Recognized Expert Contributor
    • May 2007
    • 407

    #2
    Originally posted by ahd2008
    Hi everybody,

    I want to create a code that subtract two years from the current date and returns the data.

    For instance

    Current date= 05/05/2009
    Date before two years=current date-(2 years)
    Date before two years=MM/DD/YYYY

    Appreciate your cooperation
    Hi,

    The function you want is DateAdd

    [CODE=vb]dtPrevious = DateAdd("yyyy", -2, dtCurrent)[/CODE]

    Please read the help file for DateAdd for further usage of the Interval argument ("yyyy" in this example).

    Jim

    Comment

    • ahd2008
      New Member
      • Nov 2008
      • 68

      #3
      thanks a lot bro and thx for the advice too

      Comment

      • JustJim
        Recognized Expert Contributor
        • May 2007
        • 407

        #4
        No problem, glad to be of assistance.

        Jim

        Comment

        Working...