hellismyrestingplace
hellismyrestingplace
KPCKevin Powell - Community
Created by hellismyrestingplace on 4/16/2025 in #help
Sum Count Of Weekend Days In Overlapping Periods (MySQL)
it works
411 replies
KPCKevin Powell - Community
Created by hellismyrestingplace on 4/16/2025 in #help
Sum Count Of Weekend Days In Overlapping Periods (MySQL)
but hey
411 replies
KPCKevin Powell - Community
Created by hellismyrestingplace on 4/16/2025 in #help
Sum Count Of Weekend Days In Overlapping Periods (MySQL)
the weekend count part
411 replies
KPCKevin Powell - Community
Created by hellismyrestingplace on 4/16/2025 in #help
Sum Count Of Weekend Days In Overlapping Periods (MySQL)
even i barely understand it
411 replies
KPCKevin Powell - Community
Created by hellismyrestingplace on 4/16/2025 in #help
Sum Count Of Weekend Days In Overlapping Periods (MySQL)
indeed
411 replies
KPCKevin Powell - Community
Created by hellismyrestingplace on 4/16/2025 in #help
Sum Count Of Weekend Days In Overlapping Periods (MySQL)
411 replies
KPCKevin Powell - Community
Created by hellismyrestingplace on 4/16/2025 in #help
Sum Count Of Weekend Days In Overlapping Periods (MySQL)
ai came up with it, groq 3 model
411 replies
KPCKevin Powell - Community
Created by hellismyrestingplace on 4/16/2025 in #help
Sum Count Of Weekend Days In Overlapping Periods (MySQL)
$query->leftJoin(\DB::raw('(
SELECT
apartment_id,
SUM(DATEDIFF(LEAST("' . $checkOut . '", end), GREATEST("' . $checkIn . '", start)) * price) AS total_special_price,
SUM(DATEDIFF(LEAST("' . $checkOut . '", end), GREATEST("' . $checkIn . '", start))) AS special_days_count,
SUM(
FLOOR(DATEDIFF(LEAST(DATE_SUB("' . $checkOut . '", INTERVAL 1 DAY), DATE_SUB(end, INTERVAL 1 DAY)), GREATEST("' . $checkIn . '", start)) / 7) * 2
+ (MOD(DATEDIFF(LEAST(DATE_SUB("' . $checkOut . '", INTERVAL 1 DAY), DATE_SUB(end, INTERVAL 1 DAY)),
GREATEST("' . $checkIn . '", start)), 7) >= ((4 - WEEKDAY(GREATEST("' . $checkIn . '", start)) + 7) % 7))
+ (MOD(DATEDIFF(LEAST(DATE_SUB("' . $checkOut . '", INTERVAL 1 DAY), DATE_SUB(end, INTERVAL 1 DAY)),
GREATEST("' . $checkIn . '", start)), 7) >= ((5 - WEEKDAY(GREATEST("' . $checkIn . '", start)) + 7) % 7))
) AS special_weekend_days_count
FROM special_prices
WHERE start < "' . $checkOut . '" AND end > "' . $checkIn . '"
GROUP BY apartment_id
) AS sp'), 'sp.apartment_id', '=', 'a.id');
$query->leftJoin(\DB::raw('(
SELECT
apartment_id,
SUM(DATEDIFF(LEAST("' . $checkOut . '", end), GREATEST("' . $checkIn . '", start)) * price) AS total_special_price,
SUM(DATEDIFF(LEAST("' . $checkOut . '", end), GREATEST("' . $checkIn . '", start))) AS special_days_count,
SUM(
FLOOR(DATEDIFF(LEAST(DATE_SUB("' . $checkOut . '", INTERVAL 1 DAY), DATE_SUB(end, INTERVAL 1 DAY)), GREATEST("' . $checkIn . '", start)) / 7) * 2
+ (MOD(DATEDIFF(LEAST(DATE_SUB("' . $checkOut . '", INTERVAL 1 DAY), DATE_SUB(end, INTERVAL 1 DAY)),
GREATEST("' . $checkIn . '", start)), 7) >= ((4 - WEEKDAY(GREATEST("' . $checkIn . '", start)) + 7) % 7))
+ (MOD(DATEDIFF(LEAST(DATE_SUB("' . $checkOut . '", INTERVAL 1 DAY), DATE_SUB(end, INTERVAL 1 DAY)),
GREATEST("' . $checkIn . '", start)), 7) >= ((5 - WEEKDAY(GREATEST("' . $checkIn . '", start)) + 7) % 7))
) AS special_weekend_days_count
FROM special_prices
WHERE start < "' . $checkOut . '" AND end > "' . $checkIn . '"
GROUP BY apartment_id
) AS sp'), 'sp.apartment_id', '=', 'a.id');
411 replies
KPCKevin Powell - Community
Created by hellismyrestingplace on 4/16/2025 in #help
Sum Count Of Weekend Days In Overlapping Periods (MySQL)
i warned u
411 replies
KPCKevin Powell - Community
Created by hellismyrestingplace on 4/16/2025 in #help
Sum Count Of Weekend Days In Overlapping Periods (MySQL)
well
411 replies
KPCKevin Powell - Community
Created by hellismyrestingplace on 4/16/2025 in #help
Sum Count Of Weekend Days In Overlapping Periods (MySQL)
so im good
411 replies
KPCKevin Powell - Community
Created by hellismyrestingplace on 4/16/2025 in #help
Sum Count Of Weekend Days In Overlapping Periods (MySQL)
from 0.48s slowed down to 0.49s
411 replies
KPCKevin Powell - Community
Created by hellismyrestingplace on 4/16/2025 in #help
Sum Count Of Weekend Days In Overlapping Periods (MySQL)
its a raw sql query
411 replies
KPCKevin Powell - Community
Created by hellismyrestingplace on 4/16/2025 in #help
Sum Count Of Weekend Days In Overlapping Periods (MySQL)
the code is ugly tho
411 replies
KPCKevin Powell - Community
Created by hellismyrestingplace on 4/16/2025 in #help
Sum Count Of Weekend Days In Overlapping Periods (MySQL)
almost none
411 replies
KPCKevin Powell - Community
Created by hellismyrestingplace on 4/16/2025 in #help
Sum Count Of Weekend Days In Overlapping Periods (MySQL)
i found the solution i was looking for, and it has minimal performance impact
411 replies
KPCKevin Powell - Community
Created by hellismyrestingplace on 4/16/2025 in #help
Sum Count Of Weekend Days In Overlapping Periods (MySQL)
it deserves some rewrite for the 10 years
411 replies
KPCKevin Powell - Community
Created by hellismyrestingplace on 4/16/2025 in #help
Sum Count Of Weekend Days In Overlapping Periods (MySQL)
rawrite is due anyway
411 replies
KPCKevin Powell - Community
Created by hellismyrestingplace on 4/16/2025 in #help
Sum Count Of Weekend Days In Overlapping Periods (MySQL)
well knowing the ol code im sure theres unecessary records being fetched
411 replies
KPCKevin Powell - Community
Created by hellismyrestingplace on 4/16/2025 in #help
Sum Count Of Weekend Days In Overlapping Periods (MySQL)
a slow mf
411 replies