Memformat timestamp menjadi string dengan format tertentu. Sangat berguna untuk menampilkan tanggal dalam format custom.
VARCHARDiperbarui: 13 Jun 2026STRFTIME(timestamp, format)Nilai tanggal atau timestamp yang akan diformat
String format menggunakan specifier seperti %Y, %m, %d, %H, %M, %S
1 SELECT STRFTIME(NOW(), '%d-%m-%Y');
Format tanggal style Indonesia (DD-MM-YYYY).
1 SELECT STRFTIME(NOW(), '%Y-%m-%d %H:%M:%S');
Format ISO 8601 style.
1 SELECT 2 order_id, 3 STRFTIME(order_date, '%d %B %Y') as formatted_date 4 FROM orders;
Format tanggal untuk display (contoh: 15 March 2024).
| order_id | formatted_date |
|---|---|
| 1 | 15 March 2024 |
| 2 | 14 March 2024 |
1 SELECT 'backup_' || STRFTIME(NOW(), '%Y%m%d_%H%M%S') || '.sql' as filename;
Membuat nama file dengan timestamp.
1 SELECT 2 STRFTIME(order_date, '%Y-%m') as year_month, 3 COUNT(*) as orders, 4 SUM(amount) as revenue 5 FROM orders 6 GROUP BY STRFTIME(order_date, '%Y-%m') 7 ORDER BY year_month;
Grouping dengan format year-month.
Sudah paham STRFTIME? Latih langsung di browser
Latihan interaktif, langsung di browser.