Results 1 to 10 of 10
  1. #1
    Join Date
    May 2020
    Posts
    8

    Missing Expressions

    Hello, complete novice looking for a leg up here please:

    Using a calcualted field I need to add x number of weeks to a date I already have in another field.
    Google tells me the way to do this is with the DateAdd expression.
    However in expression builder, DateAdd doesn't appear.
    If I type it in directly using the syntax Google tells me to, Access says it's invalid when I try and save the table.

    Driving me nuts, any help hugely appreciated.

    Thanks,


    A

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    =DateAdd("d",42,[dateFld])

    d = days, it may allow weeks, I didn't check.

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,540
    I think you need to give us a bit more to work with. We know the syntax, as you you now that googled it, so no point in us posting that.
    Show us what you've tried that give you errors.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #4
    Join Date
    May 2020
    Posts
    8
    Hi, thanks for the replies.
    I guess the "first" issue is that I can't see DateAdd in expression builder:
    Click image for larger version. 

Name:	dateadd.JPG 
Views:	9 
Size:	52.7 KB 
ID:	42011

    If I type "date" in the expression builder window at the top, the only function that pops up as availble is "DateSerial".

    That aside, if I just hand type the following in the expression builder:
    Click image for larger version. 

Name:	expression.JPG 
Views:	9 
Size:	23.7 KB 
ID:	42012

    I get this when I hit ok:
    Click image for larger version. 

Name:	dateadd_error.JPG 
Views:	9 
Size:	19.6 KB 
ID:	42013

    Hope that makes sense?
    Sure I'm missing something obvious...

    Thanks,
    A

  5. #5
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Can you clarify - Calculated Field - Is this in the Table design or a Query?
    If it's a Table (as I suspect it is from your OP) I would advise against it, and simply do the calculation in a query when you need it.

    Is [Timeline - Phase 0 complete] or [Timeline - Phase 1 complete] already a calculated field?

    I note you have both from your screen shots, is one a typo, and also please remove the spaces and special characters from your field names, they will cause you grief and heaps of extra typing during development.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  6. #6
    Join Date
    May 2020
    Posts
    8
    Thanks,
    It's in a table deisgn, but I guess eitehr way DateAdd should at least appear in expression builder, no?
    Yes, both of the fields are already calcluated. Neither is a typo, they both exist - I just used a different one in each exmaple by mistake.

    Thanks for the tip on spaces.

    Presumably there's still something up whether I use a query or not?

  7. #7
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    DateAdd isn't available as a calculated field expression. They are quite restricted on what you can and can't do with them, hence often easier to avoid.
    I'm pretty sure they also can't be indexed so their potential use to save processing in a query is negated by them being slow in searches(in large data sets).

    if you really want to pursue it you can simply add a number of days [MyDate] + 14 would add two weeks.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  8. #8
    Join Date
    May 2020
    Posts
    8
    Juts to add, I tried the same expression with a non-calcualted field (just a field formatted Medium Date), I still got the same error as above.

  9. #9
    Join Date
    May 2020
    Posts
    8
    Quote Originally Posted by Minty View Post
    DateAdd isn't available as a calculated field expression. They are quite restricted on what you can and can't do with them, hence often easier to avoid.
    I'm pretty sure they also can't be indexed so their potential use to save processing in a query is negated by them being slow in searches(in large data sets).

    if you really want to pursue it you can simply add a number of days [MyDate] + 14 would add two weeks.
    Got it thanks - posted the above before I saw this reply.
    Thank you!

  10. #10
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Quote Originally Posted by manifold1978 View Post
    Got it thanks - posted the above before I saw this reply.
    Thank you!
    You are welcome - good luck with the rest of your project.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

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

Similar Threads

  1. Rounding and expressions
    By Ximena in forum Access
    Replies: 1
    Last Post: 11-02-2016, 05:49 AM
  2. If Then Expressions?
    By FoxMan250 in forum Access
    Replies: 34
    Last Post: 05-08-2014, 12:30 PM
  3. Delimiter expressions
    By kjcochran in forum Queries
    Replies: 3
    Last Post: 06-16-2013, 06:45 AM
  4. Expressions and formulas
    By kjcochran in forum Access
    Replies: 1
    Last Post: 03-25-2013, 02:19 PM
  5. Expressions in Form
    By Deb4566 in forum Access
    Replies: 7
    Last Post: 03-08-2013, 12:18 PM

Tags for this Thread

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