How to filter based on a start and end date where the dates can be null - directus

I am able to filter if the date field is null or I can filter if the date field is older than now. But, I cannot combine them, nor am I able to do this or grouping for both fields.
Is there a way to group filters?
Is there a way to check if the date is null, I want all nulls OR if the date is prior to now.
This does not work:
&filter[publish_on][lte]=now&filter[publish_on][logical]=[or]&filter[publish_on][null]

Related

select data from range of two dates

I want a query for selecting data between two dates (p_startdt,p_enddt) which is given by the user, if there is no input then by default data of last one year will be given as output. I am not able to put case for null or no input
where invc_dt between p_startdt and p_enddt
Use NVL to handle the case of a NULL value. The following example will take start date as a year ago if p_startdt is null and p_enddt as the current date if p_enddt is null:
WHERE invc_dt
BETWEEN NVL(p_startdt,ADD_MONTHS(SYSDATE,-12)) AND
NVL(p_enddt,SYSDATE)
Note: I'm assuming the data type of the column invc_dt is DATE.

How to modify SQL query to get latest date

I need to obtain the latest order date in statsbestproducts module, I added it to the SQL query but I obtain the first order date (between two dates). How to change it for latest dates? And also how to remove the time from this date?
... MIN(o.date_add) AS `date` ...

Is there a way to store multiple dates into a table with potential to grow?

I have a table like this in SQLITE3:
I need to query this table by ID|DOC_ID|TRANS_DOC_ID and most importantly by DATE because I need to get the data day by day. ex: TODAY|YESTERDAY|ETC
So far the query is easy, as I can just do this to get the rows by day:
SELECT * FROM CLIENTRECORD WHERE DATE = '2020-12-01'
The problem is when I need to display specific records on other dates:
ex: I have a row with DATE 2020-12-01 but I also want it displayed on DATE 2020-01-01 or maybe 2020-01-02, etc. What do I do in this situation? and so I thought about adding another col as DATES which was supposed to be an array of comma-separated dates BUT I researched that this is a BAD solution, I also thought about adding a separate TABLE just for dates but since the dates aren't fixed (they might contain 1 date or maybe even 10 who knows), I am confused as to what I am supposed to do.
The end goal is that a row may or may not contain more than 1 date, would look something like this if I want to query for the row with or without multiple dates:
SELECT * FROM CLIENTRECORD WHERE DATE = '2020-12-01' OR DATES LIKE '2020-12-01'
something similar to it.

Is there a way to set all dates?

I was wondering, in SQL/dbt is there a way to set all dates to be >= another date?
Say I have a 'createdat' date field and a 'updatedat' date field. I use it multiple times in my query (multiple CTEs) as well as other dates. I want to make sure all dates used are less then the last day of last month (i.e. <= last_day(current_date()-30, month)).
Is there a way to set that in the beginning of the query?
This can definitely be done. You'll want to compare the greatest() of a number of columns with whatever date cut-off you want.
Effectively, it would be:
select *
from {{ ref('some_table') }}
where greatest(created_at,updated_at) < date_trunc('month', current_date)
You can obviously add as many columns to that query as you'd like.
N.B.: On some warehouses, greatest returns null if any of the columns in it are null. In that situation, you'll need to coalesce each date with some date placeholder, like '1970-01-01'.

SSRS Null Date Multi-Filtering

I have a table with three columns: Task, Assigned To and Due Date. I want to set a filter to Due Date where every date is greater than or equal to today's date. I can't post any photos, but the filter is easy enough to understand. The filter looks like this:
Due_Date >=Today()
My problem is I want to include null or blank dates, and I'm finding this to be tricky by using SSRS filters.
How can I include all dates greater than or equal to today's date or null values?
Just add an OR with your other conditions (NULL or Blank):
=IIF(FIELDS!Due_Date.VALUE >=Today OR ISNOTHING(FIELDS!Due_Date.VALUE) OR FIELDS!Due_Date.VALUE = "", True, False)