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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datediff Function

Status
Not open for further replies.

TorrediPisa

Programmer
Apr 15, 2004
67
IT
Hello to everyone.

I have some difficulties in using the function Datediff in the QBE of Access 97.
For example I simply need to calculate the number of days between the current date (Date) and each date stored in the column ReferenceDate of a Table: Therefore I write like this:

Expr1: DateDiff('d';Date();[ReferenceDate])
But when I have finished to write, the above is automatically changed into:
Expr1: DateDiff('\d';Date();[ReferenceDate])
(a backslash in written before the d parameter)
Although the ReferenceDate is always non Null, the calculation
does not have any effect and a #error is browsed under the Expr1 column.

where in yr opinion is the mistake?
Thank You for Yr time
Best Regards

TorrediPisa
 
Hi

It parameters are seperated by , not ; also try " instead of ', so

Expr1: DateDiff("d",Date(),[ReferenceDate])

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Dear KeanRay

Thank You for yr prompt reply.
Indeed I have already tried with commas instead of colon
(I used colon because in the Expression Generator is this separator which is indicated),
but I receive this message (I have the Italian version, therefore I try to translate the sense):
"Missing Operator, Character or Comma not valid or text not included between quotes".
I am certain to have duly copied the string you indicated.

What do you think about??
Thanks again
Torredipisa
 
Hi

Difficult for me to check out Italian version

why not try typing similar expression in vba immediate window until you are sure you have syntax correct, then apply in query

Hope this helps

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi KenReay

I have found the problem!
The fact is that every access language version has its parameter names.
In my case the error was to indicate 'd' for days, I should have indicated 'g' which is for giorni (days in italian). The same happens if I do want 'yyyy' (Year) which in italian is 'aaaa'.
The only thing which I have not yet understood is why the expression accept colons(;) instead of commas(,) as it is commonly indicated in every manual.

Well, sorry for keeping you mind-occupated.
Thanks again for yr time.
Regads
TorrediPisa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top