Results 1 to 9 of 9
  1. #1
    raytackettsells is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    27

    Calculate Date in Query

    Hi there,



    My programming knowledge is noob at best. I already have an expression in the Date Due field to format it correctly. Is there a way to have the date that is already in the table (SHEET1) to be calculated in the Query1 to add ONE day less than the date which is displayed. Sorry for my lack of knowledge but thanks a lot to anyone who helps me. Example

    Date Due = 03/26/2012
    Calculated Date = 03/25/2012

    Thanks again!

    Ray

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You can use the DateAdd() function to subtract a day.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    raytackettsells is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    27
    I tried to add it into the syntax and forgive me if it looks wrong now but you get the idea. in the field column there is a format expression MMDDYYYY, and id add that into CRITERIA in the query right like, DateAdd("d",-1,[Date Due]) or is it different because now the field shows as well is exported as Expr1...so should I change it to that? Thanks for the help>

  4. #4
    raytackettsells is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    27
    I tried that and it works if I add a separate Due Date to the query so there are two...but I need it not only to calculate the field its in but also change it from that calculated field to MMDDYYYY no dashes. So basically I can get it to remove the dashes and now with your help know how to remove a day but how to get them to calc in the same field. Thanks

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'm not clear on the overall goal. If you just want that value for display, you'd have that in the Field pot, not the Criteria. Access will alias it to Expr1, which you cn change to something more descriptive.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    raytackettsells is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    27
    the goal is its imported from excel and is like 03/22/2012 I need to export to text and have it only be 8 bytes so i can do it inside the query using that format expression but dont know how to also have it calc and leave in that format...

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You should be able to combine them:

    Format(DateAdd("d",-1,[Date Due]), "MMDDYYYY")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    raytackettsells is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    27
    Worked like a charm! Thanks a lot! Its awesome I always think that there is a platform like this where people like yourself are willing to be so helpful.

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    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. Replies: 34
    Last Post: 12-01-2011, 08:18 AM
  2. Expr. to calculate 'Age' from Date field
    By JohnB47 in forum Queries
    Replies: 18
    Last Post: 08-17-2011, 04:10 AM
  3. Replies: 1
    Last Post: 11-12-2010, 01:16 AM
  4. Replies: 4
    Last Post: 10-27-2010, 02:57 PM
  5. Calculate age from birth date
    By mick in forum Forms
    Replies: 2
    Last Post: 07-03-2010, 04:31 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