date/now function

barnyb3

Registered User.
Local time
Today, 11:30
Joined
Apr 21, 2008
Messages
11
I am writing a database for a theoretical taxi company.

I want to use date function to show all jobs to be done.

How should I use a date function/now function to show all jobs that are due from the current time/date.

I know the function exists I just don't know how to use it as I am a learner.

Cheers barny
 
Don't post the question more than once in the forums!
 
The Date() function returns the current date only and Now() function returns the current date and time. You could use the Date() function to compare dates that exist in your DB with the current date. I would not use the Now() function, as unless your time matches to the second you will not get a match.

As SOS pointed out please don't post the same question more than once.
 
Last edited:
As John said, always use Date() when you're going to be comparing dates, as you are here. Only use Now() if you have a specific reason for needing the tim as well as date.

You really haven't given us much data as to what/how you're trying to do this, but the general syntax for comparing dates would be

Me.ServiceDate >=Date()

or as the Criteria in a Query

[ServiceDate] >=Date()

where ServiceDate is the name of the textbox (in a form) or field (in a tebale/query.)
 
I work for a real taxi company. You could use the Date or Now functions along with the DateAdd function to find jobs that are due within a certain time frame from now.
 
Any idea why Date() would be returning a null value in my db? I've used the function in the past on other dbs with no issues, but for some reason, nothing is returned. As a test, I have two message boxes pop up

Code:
MsgBox "Now = " & Now
MsgBox "Date = " & Date

The 1st box displays "Now = 12/27/2008 1:33:19 PM" as expected.
The 2nd box only displays "Date = ".

Any idea what I'm missing? Thanks.

Bruce
 
Are you, by chance, using Date as the name for a field ? If so, change it to something else and see what happens.
 
My first guess would be that there's a field named "date", and Access is giving you that. If so, you should change it, but a workaround would be:

MsgBox "Date = " & VBA.Date
 
Thanks guys. I really feel like an idiot now... I was using "Date" elsewhere just as you suspected. I'm blaming the cough medicine for me being a ding bat. :D
 

Users who are viewing this thread

Back
Top Bottom