Syntax for filtering view by Date field

Study Forum (Inactive)
Syntax for filtering view by Date field rosnerd  2011-02-08 10:23
Status: Closed
 
In an observational study, I'd like to filter a view by
Datetime field and select observations less than 24 hours old.

The customize Grid View interface will let me set up a filter
to select based on a specific date syntax like 2011-02-06, but is it currently
possible to select based on something more dynamic,
roughly like Date - 24 hours, for example?

I wasn't able to find anything about this looking through the
tutorial or docs. Can it be done in the customize view grid?

Dan
 
 
Matthew Bellew responded:  2011-02-08 11:03
We don't have support for this in 10.3. One solution would be to create a wiki page, that has a bit of script to generate the correct filter and give the user a link to click, or include a query web part.

In 11.1 we will add partial support for this. It's not supported in the filter dialog UI, but the client api and URL syntax support a date relative filter. In the URL it would look like this

  ?query.date~dategte=-1d

~dategte means to use date (w/o time) comparison rather than date/time.
-1d means "now() - 1 day"

This syntax will only works with the "~date" comparison operators.

Matt
 
rosnerd responded:  2011-02-08 22:29
Thank you for the information.

Just in case this helps someone with
similar problem, I ended up creating a
custom query and used Labkey SQL functions
in the where clause to select dates less than
one day old, like this:

where myTable.Date > TIMESTAMPADD(SQL_TSI_DAY, -1, now())


Then I built my R view off this result set.


Dan