Convert strftime to SQLite query for MySQL

I converted the SQLite string

WHERE strftime('%d%m', orders.created_at) = .......

directly to the MySQL monster:

WHERE CONCAT(CAST(DAY(orders.created_at) AS CHAR), LPAD(CAST(MONTH(orders.created_at) AS CHAR), 2, '0')) = .........

Please help me rewrite it to a shorter one.

+4
source share
1 answer

STRFTIME () in SQLite is similar to DATE_FORMAT () in MySQL with modified parameters.

Since %dand %mare compared with the same in both, your expression could simply be written as:

WHERE DATE_FORMAT(orders.created_at, '%d%m') = .......
+10
source

Source: https://habr.com/ru/post/1545636/


All Articles