What am I doing wrong??-Datediff

wakiwi

Registered User.
Local time
Today, 12:56
Joined
Mar 2, 2005
Messages
14
I am trying to calculate the total number of days between a date (i.e, csdate) and todays date in a Query for a Report.
I have tried the DateDiff command in the query line and in an unbound box on the report but it is not returning the right values.
Can Someone tell me what I have done wrong. I have checked that the date is in long format and tried it in short format as well with the same results. Below is what I have tried.
csdays:=DateDiff("d", [csdate], Date()) I have tried the Now() command as well, but it is not right either.
Please help!
 
Using this as a calculated field in a query works:
dtdiff: DateDiff("d",[ValidDateFieldFromTheTable],Date())
 
I know it should have worked but it did not. I finally got it to work using the following
=(Date()-[fieldname])/365*12*30.
 
Instead of this,

Code:
csdays:=DateDiff("d", [csdate], Date())

have you tried this:

Code:
csdays=DateDiff("d", [csdate], Date)

without using the parentheses for "Date" and without the colon after csdays
 
=DateDiff("d",[Csdate],Date())

will work as the Controlsource on a form or report

In a query use

csdays: DateDiff("d",[Csdate],Date())

or Date()-[CsDate]
 
Thanks to all for helping. It must have been some quirk with the program or something else I can't explain. When I deleted the variable from the table, closed the table, then reopened it rentered the same info, with the same field name even, the query worked just fine!
csdays: DateDiff("d",[Csdate],Date())

Thanks again though, this site is WONDERFUL, I have recieved much help here!
 
wakiwi said:
Thanks to all for helping. It must have been some quirk with the program or something else I can't explain. When I deleted the variable from the table, closed the table, then reopened it rentered the same info, with the same field name even, the query worked just fine!
csdays: DateDiff("d",[Csdate],Date())

Thanks again though, this site is WONDERFUL, I have recieved much help here!

The first time you had csdays:=

the = was probably throwing it off.
 

Users who are viewing this thread

Back
Top Bottom