Results 1 to 8 of 8
  1. #1
    Mohibullah is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    25

    Adding a new date in a field, based on adding integers from one field, to an existing date field

    Hi,

    I was wondering how to take a date field(DateField1) that exists, and add a number(NumberField), to create a date in another field(DateField2) that is DateField1+NumberField in a date format. So for example.


    DateField1 NumberField DateField2

    mm/dd/yyyy mm/dd/2007

    10/11/2007 10 10/21/2007 <-----How do I get this by adding (10/11/2007+10) in either code form, macro, or expression????



    Much Appreciated!!!

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You can use the DateAdd() function pretty much anywhere.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Mohibullah is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    25
    Quote Originally Posted by pbaldy View Post
    You can use the DateAdd() function pretty much anywhere.

    I tried using the DateAdd function for this, but couldn't get it to work. I also tried DatePart. Could you give me an example of how you might make this work?

    Thanks for the quick response!

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Why don't you post what you tried and how didn't work, and we'll fix it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Mohibullah is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    25
    Quote Originally Posted by pbaldy View Post
    Why don't you post what you tried and how didn't work, and we'll fix it.
    Sure thing.

    DateAdd("d",[tbl2Jurisdiction_TimeFrame]![Tiimeframe (Days)],[tbl1Project]![PermitApp])

    I chose d for days. The field I chose for the number has the integer with which to add days to the last piece, which is the date. This calculation is in the calculated field for another column/field that will be the PermittApp date, but the number of days ahead in TiimeFrame (Days).

  6. #6
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Ah. Remember I said it would work pretty much anywhere? One place it won't is a calculated field at the table level. The other issue there is that you can't use fields from a different table.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Where are you using this expression - in a form or query? If you are trying to use a calculated table field, I suggest you don't because a) calculated data should be queries, and b) the expressions you can use in a calculated table field are VERY limited.

    If you are using it in a query, the syntax is incorrect - you can't refer to a table field with the "!" as you can with form controls. What is the error message you get (if any)?

  8. #8
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I'll get out of the way.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Adding a Calculated Date Field to a Query
    By MFriend in forum Access
    Replies: 8
    Last Post: 07-24-2015, 04:00 PM
  2. Replies: 13
    Last Post: 06-11-2015, 06:41 PM
  3. Replies: 5
    Last Post: 11-18-2012, 01:27 PM
  4. Adding the day of the week to a date field
    By cschieff in forum Reports
    Replies: 2
    Last Post: 10-24-2012, 02:47 PM
  5. Replies: 10
    Last Post: 04-21-2010, 01:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums