Results 1 to 5 of 5
  1. #1
    Helge12 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    3

    Arrow Problem with DateDiff

    Hello,

    My name is Helge and I am looking for some help. I have never used Microsoft Access until a few hours ago and for that reason I hope you can overlook if I sound stupid. I'm trying to follow the instructions shown in this video tutorial (link below). The end goal is to be able to show a countdown timer in a PowerPoint presentation. But I can't seem to get the database in Access 2016 to work. As I said, I never used it before and spent a couple of hours trying to figure out what to do by googling and using the help section to no luck.

    https://www.youtube.com/watch?v=PzWVUBslby8


    1. I have created a table called "TableTargetDate" which basically is a row with two columns named ID and Field1. ID has “1” as a value and Field1 has “2018-02-01”.
    2. After that I clicked on Create -> Query Wizard -> Simple Query Wizard. From “Available Fields:” I choose ID and Field1 then clicked finished.
    3. I renamed the thing I just created from “TableTargetDate Query” to “QueryTargetDate”. Not sure if it matters but in the video that’s the name they are using.
    4. I right clicked on the query and went into Design View -> SQL View.
    5. I wrote the code in the box from what was shown in the video:


    Code:
     SELECT Format(DateDiff([“d”],Now(),[Target]),[”00”]) AS days, Format(DateDiff([“h”],Now(),[Target]) Mod 24,[”00”]) AS hours, Format(DateDiff([“n”],Now(),[Target]) Mod 60,[”00”]) AS minutes, Format(DateDiff([“s”],Now(),[Target]) Mod 60,[”00”]) AS seconds FROM TableTargetDate;
    When I click on “Run” it opens up a dialogue box and its asking: Enter Parameter value “d”. Regardless if I write a value or not, after I click ok its asking for parameter values for: Target, “00”, “h”, “n”, “s”. Then it says the phrase is either to complex or wrong. Ive compared the code to the one shown in the video several times and I can't see any difference. I's there some connection between the boxes in Design View on Queries that must be done or what?



    I would be grateful if anyone, in some easy, way could explain what I need to do to get it to work.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Incorrect use of [].

    Format(DateDiff("d", Now(), [Target]), "00")

    Brackets in query are used to define objects - field, control, table, query, form, report.

    In tutorials the [] can be used to designate something you have to provide - [use what you prefer here] - but the brackets would be dropped.

    Also, the quote marks in your posted example may need to be replaced with ". Note the different style. I am baffled how your posted example has the wrong style if you typed the SQL in the designer.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Helge12 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    3
    Quote Originally Posted by June7 View Post
    Incorrect use of [].

    Format(DateDiff("d", Now(), [Target]), "00")

    Brackets in query are used to define objects - field, control, table, query, form, report.

    In tutorials the [] can be used to designate something you have to provide - [use what you prefer here] - but the brackets would be dropped.

    Also, the quote marks in your posted example may need to be replaced with ". Note the different style. I am baffled how your posted example has the wrong style if you typed the SQL in the designer.
    Thank you for taking the time. I noticed I copied the wrong code in my previous post, sorry about that. The brackets around "d", "h", "n" and "s" where something I tried earlier after reading some tutorial but I guess I got it wrong. But you are right about the quote marks. I've changed it now and tried again, this time I only get Enter Parameter value dialouge box for “Target”. Should I drop the brackets around that aswell or does Target need to be replaced with something? This is the code that I'm using in SQL View:

    SELECT Format(DateDiff("d",Now(), [Target]),"00") AS days, Format(DateDiff("h",Now(),[Target]) Mod 24,"00") AS hours, Format(DateDiff("n",Now(),[Target]) Mod 60,"00") AS minutes, Format(DateDiff("s",Now(),[Target]) Mod 60,"00") AS seconds
    FROM TableTargetDate;

    This is what it looks like in Design View:

    Click image for larger version. 

Name:	Namnlös.png 
Views:	16 
Size:	27.8 KB 
ID:	32285

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Target is just a generic reference used in tutorial and should be replaced with actual field name from your table.

    Field1 is not descriptive. Should give your objects more informative names.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Helge12 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    3
    Quote Originally Posted by June7 View Post
    Target is just a generic reference used in tutorial and should be replaced with actual field name from your table.

    Field1 is not descriptive. Should give your objects more informative names.
    I got it working now, thank you!

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

Similar Threads

  1. Datediff
    By JediPhantom in forum Queries
    Replies: 1
    Last Post: 02-04-2016, 12:44 PM
  2. datediff problem
    By sdel_nevo in forum Programming
    Replies: 5
    Last Post: 06-28-2015, 05:26 AM
  3. Replies: 13
    Last Post: 10-12-2011, 11:08 AM
  4. datediff problem
    By dseeburg in forum Queries
    Replies: 3
    Last Post: 04-07-2011, 06:05 AM
  5. DateDiff
    By mrkaye in forum Forms
    Replies: 18
    Last Post: 11-19-2010, 08:19 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