I have the following table :
A header | Another header |
---|---|
First | row |
Second | row |
IDno | name | date | status |
---|---|---|---|
c123 | Ryan | 10/05/2024 | arrival |
f738 | Tom | 10/05/2024 | arrival |
c123 | Ryan | 13/05/2024 | arrival |
f738 | Tom | 16/05/2024 | departure |
I want to using Datediff function to count length of the days from the arrival date. So the result would be like this :
| IDno | name | date | status | days |
|——| ——| ———–|———-|——|
| c123 | Ryan | 10/05/2024 | arrival | 3 | –> between arrival date if no departure
| f738 | Tom | 10/05/2024 | arrival | 6 | –> between departure date
| c123 | Ryan | 13/05/2024 | arrival | 6 | –> between current date
My queries just like this :
SELECT *, DATEDIFF(now(),date) as days FROM mytable WHERE status = 'arrival';
I know it doesn’t work. I must add other function in my DATEDIFF(). How to count the days from the specific condition ?