Results 1 to 3 of 3
  1. #1
    EileenAchil is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2016
    Posts
    3

    DATE Minus 1 day

    Hi , my date field name is TransDate and i want to minus the date -1. Anyone know how? My situation is if the time is less than 8pm and the shift is night , so the transdate will minus one. Eg. If today is 29 dec then it should change to 28 dec
    Code:
    IIF ( record.time<#20:00:00#) AND (calendar.shift = "Night"), record.date -1, "-") AS scantype


    The code error is undefined function.

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Worked for me with a few alterations.

    Perhaps change the field names (date and time are key phrases in access so aren't used to avoid confusion)
    Are you calculating the field transdate?

    I left off as scantype (sql??)

    And if your fields are date/time fields, the iif statement cannot return your false value of "-"

    I used

    iif([time1]<#8:00:00 pm#, [date1]-1,[date])


    Sent from my iPhone using Tapatalk

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    "Time" and "Date" are reserved words in Access and shouldn't be used as object names. Plus, they are built-in functions.

    Are you trying to use this in a query? If so, please post the SQL of the query.

    Maybe this??
    Code:
    IIf(TimeValue([TransDate]) < #8:00:00 PM# And (shift = "Night"), [TransDate] - 1, "-")   AS scantype

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

Similar Threads

  1. Date minus zeven days, How hard can it be ?
    By JeroenMioch in forum Access
    Replies: 4
    Last Post: 11-10-2014, 09:07 AM
  2. Replies: 8
    Last Post: 10-20-2012, 11:25 AM
  3. minus date wise sales a=n?
    By alex_raju in forum Access
    Replies: 1
    Last Post: 07-30-2011, 01:23 PM
  4. Date Add 26 weeks minus 1 day
    By ker9 in forum Queries
    Replies: 3
    Last Post: 07-26-2011, 01:20 PM
  5. Replies: 1
    Last Post: 04-15-2010, 02:07 AM

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