Results 1 to 8 of 8
  1. #1
    sifuhall is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    9

    Adding a dash to a date

    In my report I want to add a dash to a date field, but only when it has data so it will read like this:
    - 05/16/2018


    I have tried setting the control source to:


    iif(isnull(EndDate]), "", " - " & [EndDate]

    but that gives an error.

  2. #2
    RayMilhon is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,067
    You forgot to close the IIF statement

    IIF(isNull(Enddate]),"","-" & [Enddate])

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    but that gives an error.
    fairly simple answer this time but in the future, if you get an error, tell us what the error is - number and description. You'll get more focussed and faster help that way

  4. #4
    Minty is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,002
    If EndDate is a stored date field you won't be able to.
    The dash wouldn't be an acceptable part of the date, or would turn it into a date somewhere near a black hole event horizon.
    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 ↓↓

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    good point - you could use the format function

    IIF(isNull(Enddate]),"",format([Enddate]," - dd/mm/yyyy"))

  6. #6
    sifuhall is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    9
    Quote Originally Posted by Ajax View Post
    good point - you could use the format function

    IIF(isNull(Enddate]),"",format([Enddate]," - dd/mm/yyyy"))

    Thanks everyone for all the help.

    Using this returns:
    #Type!

  7. #7
    Minty is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,002
    If you are doing this in the report you'll need an = at the front.

    Code:
    = IIF(isNull(Enddate]),"",format([Enddate]," - dd/mm/yyyy"))
    I'd probably create this in the query personally

    DisplDate : IIF(isNull(Enddate]),"",format([Enddate]," - dd/mm/yyyy"))
    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
    sifuhall is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    9
    Great idea!

    Sometimes the best answers are the simplest and I'm trying to make this way more difficult than it needs to be.

    Thank you!

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

Similar Threads

  1. Replies: 7
    Last Post: 10-19-2016, 11:11 AM
  2. Keycode for dash/underscore key
    By data808 in forum Access
    Replies: 2
    Last Post: 03-07-2014, 11:44 AM
  3. How to eliminate the text after and before the dash
    By Jerseynjphillypa in forum Queries
    Replies: 1
    Last Post: 06-15-2012, 10:58 AM
  4. Dash Board.
    By cap.zadi in forum Forms
    Replies: 1
    Last Post: 09-14-2011, 08:10 AM
  5. Insert Dash between set of Numbers
    By Jhankish in forum Programming
    Replies: 2
    Last Post: 04-19-2007, 08:02 AM

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