A "days at" query

From: Eel <eel_at_javabox.com>
Date: 30 Jan 2002 18:51:14 -0800
Message-ID: <a62a408.0201301851.2cfba420_at_posting.google.com>



Hi,
  I'm trying to create an sql query on an ms-access database that will give me the "days at" a particular location in a factory. If I have a simple table like:

"create table transactions
date_in DATE,
date_out DATE"

I can do something like "select date_in, date_out, date_out - date_in as da from transactions"

This works, but I have a more complex requirement which is that in cases where date_out = null, ie still at a location, I want to use current_date - date_in instead of date_out - date_in. Is there a way to do this? I keep getting syntax errors.

I know I can get the information from scrolling the records, but I'd like to do it purely in sql so my report doesn't have to do its own sorting.

Thanks! Received on Thu Jan 31 2002 - 03:51:14 CET

Original text of this message