So I have a database that stores when someone leaves and when they return to.

dayleft

dayreturned

I need to do a query and also an cfif to see if a date selected is between these dates.

test - selected date

the

Here is my long if

```
<cfif (datecompare(vactrue.dayreturned, test, "yyyy") eq 0 AND datecompare(vactrue.dayreturned, test, "m") eq 0 AND datecompare(vactrue.dayreturned, test, "d") eq 0)
OR (datecompare(vactrue.dayreturned, test, "yyyy") eq -1)
OR (datecompare(vactrue.dayreturned, test, "yyyy") eq 0 AND datecompare(vactrue.dayreturned, test, "m") eq 0 AND datecompare(vactrue.dayreturned, test, "d") eq -1)
OR (datecompare(vactrue.dayreturned, test, "yyyy") eq 0 AND datecompare(vactrue.dayreturned, test, "m") eq -1 AND datecompare(vactrue.dayreturned, test, "d") eq -1)
OR (datecompare(vactrue.dayreturned, test, "yyyy") eq 0 AND datecompare(vactrue.dayreturned, test, "m") eq -1 AND datecompare(vactrue.dayreturned, test, "d") eq 0)
OR (datecompare(vactrue.dayreturned, test, "yyyy") eq 0 AND datecompare(vactrue.dayreturned, test, "m") eq -1 AND datecompare(vactrue.dayreturned, test, "d") eq 1)>
<cfif (datecompare(vactrue.dayleft, test, "yyyy") eq 0 AND datecompare(vactrue.dayleft, test, "m") eq 0 AND datecompare(vactrue.dayleft, test, "d") eq 0)
OR (datecompare(vactrue.dayleft, test, "yyyy") eq 1)
OR (datecompare(vactrue.dayleft, test, "yyyy") eq 0 AND datecompare(vactrue.dayleft, test, "m") eq 0 AND datecompare(vactrue.dayleft, test, "d") eq 1)
OR (datecompare(vactrue.dayleft, test, "yyyy") eq 0 AND datecompare(vactrue.dayleft, test, "m") eq 1 AND datecompare(vactrue.dayleft, test, "d") eq 1)
OR (datecompare(vactrue.dayleft, test, "yyyy") eq 0 AND datecompare(vactrue.dayleft, test, "m") eq 1 AND datecompare(vactrue.dayleft, test, "d") eq 0)
OR (datecompare(vactrue.dayleft, test, "yyyy") eq 0 AND datecompare(vactrue.dayleft, test, "m") eq 1 AND datecompare(vactrue.dayleft, test, "d") eq -1)>
```

Here is my query

```
<cfquery datasource="residents5" name="hosptrue">
SELECT *
FROM hospital
WHERE ID = 193 AND dayreturned IS NOT NULL
AND (DATEDIFF(dayleft, #test#) >= 0 AND DATEDIFF(#test#, dayreturned) <= 0)
</cfquery>
```

Neither of these seemed to work and was hoping that someone could enlighten me to my errors. Thanks!!!!!