Changing Times in MariaDB
This guide explores MariaDB functions for performing calculations and modifications on date and time values, like DATE_ADD and DATE_SUB.
Calculating Time Across Midnight
-- Example: Calculating a promised time 2 hours (7200 seconds) from current time
INSERT INTO tickets (client_id, urgency, trouble, ticket_date, entered, promised)
VALUES ('some_client', 'ASAP', 'Issue details',
CURDATE(), CURTIME(),
SEC_TO_TIME(TIME_TO_SEC(CURTIME()) + 7200));-- Corrected calculation for 'promised' TIME, wraps around 24 hours
SEC_TO_TIME((TIME_TO_SEC(CURTIME()) + 7200) % 86400)Tracking Date Changes with Time: Using DATETIME
DATETIMEAdding Durations with DATE_ADD
DATE_ADDDate Calculations Across Months and Years with DATE_ADD
DATE_ADDSubtracting Durations
Last updated
Was this helpful?

