Hi Tek-Tips folks!
My office has a table with information on cases. The table has fields for each case’s open date and close date. We’d like to get a new field, “TimeTaken,” with the time (in year-day-month format) between the case’s open date and close date. I know that DateDiff can help me. But I’m a newbie, and I’m having problems with the syntax.
Here’s what I ventured so far (in SQL):
Code:
SELECT CaseNumber, DateOpen, DateClose,
Format(DateDiff(“yyyy-mm-dd”, DateOpen, DateClose)) AS TimeTaken
FROM cases_tbl;
When I tried to run it, Access asked me for the parameters of yyyy, mm, and dd. It returned a recordset with #Error listed for every record in the TimeTaken column.
There’s a little complication, one that I don’t know how to address. Every case has an open date, but not a close date. Since we haven’t closed all cases, there are many nulls in the DateClosed field. In situations where we don’t have a DateClosed, how can I ask Access to put a “n/a” in the field for TimeTaken?
Thanks so much! This is hands-down the best forum out there…
sarajini