Last active
July 29, 2021 19:29
-
-
Save tzkmx/b8cd8b49592faf5653d212677593a6d2 to your computer and use it in GitHub Desktop.
Trigger to fix datetime offset in Laravel Nova
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR | |
ALTER PROCEDURE assets.sp_webinar_fix_utc_date @webinar_id BIGINT | |
AS | |
BEGIN | |
DECLARE @fixed_start_date DATETIMEOFFSET; | |
DECLARE @fixed_end_date DATETIMEOFFSET; | |
SET @fixed_start_date = (SELECT DATEADD(hh, 5, start_date) AT TIME ZONE 'Central Standard Time' | |
FROM assets.webinars | |
WHERE id = @webinar_id); | |
SET @fixed_end_date = (SELECT DATEADD(hh, 5, end_date) AT TIME ZONE 'Central Standard Time' | |
FROM assets.webinars | |
WHERE id = @webinar_id); | |
UPDATE assets.webinars | |
SET start_date = @fixed_start_date, | |
end_date = @fixed_end_date | |
WHERE id = @webinar_id; | |
END | |
CREATE TRIGGER assets.sp_temporal_webinar_patch_dates | |
ON assets.webinars | |
AFTER INSERT, UPDATE AS | |
BEGIN | |
DECLARE @webinar_id BIGINT; | |
SET @webinar_id = (SELECT id FROM inserted); | |
EXEC assets.sp_webinar_fix_utc_date @webinar_id; | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment