Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Today's Date in Query 1

Status
Not open for further replies.

bernie10

Technical User
Sep 13, 2004
219
US
Hey everyone,
I know this is a simple one but I could not find the answer in any previous posts.

I'm trying to create a query telling the user how many days late a project is. So I need to get the difference of the Due Date in my table and today's date.

So I would have thought it would have been:

SELECT MyTable.ID, DateDiff("d",[DateDue],[Date()]) AS DaysLate
FROM MyTable;

but Access doesn't recognize the Date() function in my expression. What am I doing wrong?

Thanks in advance for the help.

Collen
 
And this ?
SELECT MyTable.ID, DateDiff("d",[DateDue],Date) AS DaysLate
FROM MyTable;
Or this ?
SELECT MyTable.ID, DateDiff("d",[DateDue],Now) AS DaysLate
FROM MyTable;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I think, with the [brackets], Access is looking for a field named Date(), try:

[tt]SELECT MyTable.ID, DateDiff("d",[DateDue],Date()) AS DaysLate
FROM MyTable;[/tt]

If it doesn't work, I think in VBE - have a look at the references (Tools menu), and check if anyone is marked missing, invalid or something to that effect. Uncheck (and perhaps recheck) if so.

Roy-Vidar
 
Thanks for both of your replies.

Apparently the brackets were the problem. Can't believe I missed that.

Thanks again for the help.

Collen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top