Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

date expressions

Discussion in 'Information Technology' started by Code Agent, Nov 2, 2005.

  1. Code Agent

    Code Agent
    Expand Collapse
    Guest

    How do I get a field to calculate a future date based on the date in another
    field? For example, I want to be able to enter a date in a field and add 10
    days to ifferent field automaticaly.
     
  2. Loading...


  3. Ofer

    Ofer
    Expand Collapse
    Guest

    To add days to existing date, you can use that
    =DateField + 10

    Or, check help on DateAdd function
    =DateAdd("d",10,DateField) ' To add 10 days
    =DateAdd("yyyy",10,DateField) ' To add 10 years
    And more
    --
    If I answered your question, please mark it as an answer. That way, it will
    stay saved for a longer time, so other can benifit from it.

    Good luck



    "Code Agent" wrote:

    > How do I get a field to calculate a future date based on the date in another
    > field? For example, I want to be able to enter a date in a field and add 10
    > days to ifferent field automaticaly.
     
  4. Brendan Reynolds

    Brendan Reynolds
    Expand Collapse
    Guest

    Use the DateAdd function. For example, in a query ...

    SELECT tblTest.TestDate, DateAdd("d",[TestDate],10) AS TestDatePlus10
    FROM tblTest;

    In query design view, the expression looks like this (in the 'Field' row in
    the design grid) ...

    TestDatePlus10: DateAdd("d",[TestDate],10)

    In the Control Source property of a text box on a form or report, it would
    look like this ...

    = DateAdd("d",[TestDate],10)

    See "DateAdd Function" in the help files for more information.

    --
    Brendan Reynolds

    "Code Agent" <Code Agent@discussions.microsoft.com> wrote in message
    news:8F47E8E1-3757-4A3D-B2BD-9B24023A430A@microsoft.com...
    > How do I get a field to calculate a future date based on the date in
    > another
    > field? For example, I want to be able to enter a date in a field and add
    > 10
    > days to ifferent field automaticaly.
     
  5. Code Agent

    Code Agent
    Expand Collapse
    Guest

    Thanks a lot to both of you. It works perfectly! My database is finally
    complete. No more staying up late at night with visions of expressions in my
    head.

    "Ofer" wrote:

    > To add days to existing date, you can use that
    > =DateField + 10
    >
    > Or, check help on DateAdd function
    > =DateAdd("d",10,DateField) ' To add 10 days
    > =DateAdd("yyyy",10,DateField) ' To add 10 years
    > And more
    > --
    > If I answered your question, please mark it as an answer. That way, it will
    > stay saved for a longer time, so other can benifit from it.
    >
    > Good luck
    >
    >
    >
    > "Code Agent" wrote:
    >
    > > How do I get a field to calculate a future date based on the date in another
    > > field? For example, I want to be able to enter a date in a field and add 10
    > > days to ifferent field automaticaly.
     

Share This Page