SSRS Null Date Multi-Filtering - sql

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)

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.

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'.

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

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]

Limiting data on monthly basis from start date to system date dynamically in Tibco spotfire

I've tried limiting data on monthly basis in spotfire and it's working fine.
Now I'm trying to do like getting the records from the current date to month start date.
For suppose if the current date is Sept 21, then i should get the records from Sept 21 to Sept-01(dynamically).
I have a property control to input the number of months.
The easiest way to do this is with Month and Year. For example, in your visualization:
Right Click > Properties > Data > Limit Data Using Expressions (Edit)
Then, use this expression:
Month([TheDate]) = Month(DateTimeNow()) and Year([TheDate]) = Year(DateTimeNow())
This will limit the data to only those rows with the current Year/Month combination in your data column. Just replace [TheDate] with whatever your date column name is.
In other places, you can wrap this in an IF statement if you'd like. It's redundant in this case, but sometimes helps with readability.
IF(Month([TheDate]) = Month(DateTimeNow()) and Year([TheDate]) = Year(DateTimeNow()),TRUE,FALSE)
#san - Adding to #scsimon answer. If you would like to precisely limit values between 1st of the current month to current date, you could add the below expression to 'Limit data using expression' section.
[Date]>=date(1&'-'&Month(DateTimeNow())&'-'&year(DateTimeNow())) and [Date]<=DateTimeNow()

Between Date Range in a QUERY Not Working

I have a Date for Example a Departure Date of a Flight for 15/01/2014 and I want to create a query that remind me 30 days before departure.
I tried the following in the CRITERIA but none of them work
DateAdd("m",1,[DepartureDate])>=Date()
Between DateAdd("m",1,[DepartureDate]) And [DepartureDate]
IIF(DateAdd("m",1,[DepartureDate]) < Date(), True, False)
You posted this quite a while ago, so I presume you managed to solve it. But if not, here is an answer for you.
There are two ways to do this.
Option One
The easiest way is to enter this in the CRITERIA of your DepartureDate field:
=Date()+30
Option Two
Alternatively, you could create a new column in your query that you filter on. To do this in your query, enter this in the FIELD row for a new column:
30DaysAway: IIf([DepartureDate]-30=Date(),"yes","no")
This will give you a new column in the query titled "30DaysAway". In that column it will say "yes" if the departure date is 30 days away from today, and "no" for all other dates.
Then in the CRITERIA for that query field, enter "yes".
Either of these options will filter the list of results and only show you entries with a departure date that is 30 days away.