MySQL - Comparing dayname of two queries

88 Views Asked by At

I want to compare two columns Assigned_Date and Expected_Delivery_Day in my table and check if day has passed.

This is my table:

enter image description here

I tried to get the dayofweek for each column and compare the weight with IF, but im not sure how.

This is what i tried:

SELECT dayofweek(`Assigned_Date`) FROM `drvapp_routes`;

SELECT CASE 
WHEN `Expected_Delivery_Day` = 'Sunday' THEN 0
WHEN `Expected_Delivery_Day` = 'Monday' THEN 1
WHEN `Expected_Delivery_Day` = 'Tuesday' THEN 2
WHEN `Expected_Delivery_Day` = 'Wednesday' THEN 3
WHEN `Expected_Delivery_Day` = 'Thursday' THEN 4
WHEN `Expected_Delivery_Day` = 'Friday' THEN 5
WHEN `Expected_Delivery_Day` = 'Saturday' THEN 6
ELSE NULL END AS EDD
from `drvapp_routes`;

Is this the right way? How do i compare two day names and see if Assigned_Date has passed the Expected_Delivery_Day ?

0

There are 0 best solutions below