Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Team,
I am facing issue with one logic. I have two date field Start Date and End Date.
I want if Start Date=End Date,then show Active and if StartDate<End Date, then show Expired.
If(Date(StartDate,'YYYY-MM-DD'),'Active',if(Date(End Date,'YYYY-MM-DD'),'Expired') as Status
But this is not working. Any idea how to resolve this?
If( [Start Date] = [End Date], 'Active', If( [Start Date] < [End Date],'Expired','Not defined')) AS Status
assuming your dates have been interpreted as dates and are not in fact timestamps.
If you are unsure and the format of your input records is 'YYYY-MM-DD', try
SET DateFormat = 'YYYY-MM-DD';
LOAD
[Start Date],
[End Date],
If( Floor([Start Date]) = Floor([End Date]), 'Active', If( Floor([Start Date]) < Floor([End Date]),'Expired','Not defined')) AS Status,
...
If(Date(StartDate,'YYYY-MM-DD'),'Active',if(Date(End Date,'YYYY-MM-DD'),'Expired') as Status
In your IF statements there are no logic statement.
IF statement is defined as IF(condition, then, else). The first one, condition, is interpreted logically - TRUE, FALSE. The Date(StartDate,'YYYY-MM-DD') and Date(End Date,'YYYY-MM-DD') cannot be interpreted as condition that returns TRUE (-1), FALSE (0).
Please let as know if the swuehl suggestion works for you.