Dino Geek, try to help you

How to convert a date to a specific format in MariaDB?


You can use the `DATE_FORMAT()` function in MariaDB to convert a date to a specific format. The `DATE_FORMAT()` function allows you to format the date and time in a number of ways.

Suppose you have a date in the format “YYYY-MM-DD” and you want to convert it to the format “MM/DD/YYYY”. You can do it as follows:

```
SELECT DATE_FORMAT(‘2022-02-17’, ‘%m/%d/%Y’);
```

This will output: `02/17/2022`.

The `DATE_FORMAT()` function uses format specifiers which have their own special meaning:

- ‘%Y’ represents the year as a numeric, four-digit value.
- ‘%m’ represents the month as a numeric value (01, 02, …, 12).
- ‘%d’ represents the day of the month.

Some other examples:

- Convert date to DD-MM-YYYY format.

\`\`\`sql SELECT DATE\_FORMAT(‘2022-02-17’, ‘%d-%m-%Y’); \`\`\`

- Convert date and time to DD-MM-YYYY HH:MI:SS format.

\`\`\`sql SELECT DATE\_FORMAT(‘2022-02-17 13:45:30’, ‘%d-%m-%Y %H:%i:%s’); \`\`\` Remember to replace ’2022-02-17’ with the column that contains the date information in your actual SQL query.

Simply generate articles to optimize your SEO
Simply generate articles to optimize your SEO





DinoGeek offers simple articles on complex technologies

Would you like to be quoted in this article? It's very simple, contact us at dino@eiki.fr

CSS | NodeJS | DNS | DMARC | MAPI | NNTP | htaccess | PHP | HTTPS | Drupal | WEB3 | LLM | Wordpress | TLD | Domain name | IMAP | TCP | NFT | MariaDB | FTP | Zigbee | NMAP | SNMP | SEO | E-Mail | LXC | HTTP | MangoDB | SFTP | RAG | SSH | HTML | ChatGPT API | OSPF | JavaScript | Docker | OpenVZ | ChatGPT | VPS | ZIMBRA | SPF | UDP | Joomla | IPV6 | BGP | Django | Reactjs | DKIM | VMWare | RSYNC | Python | TFTP | Webdav | FAAS | Apache | IPV4 | LDAP | POP3 | SMTP

| Whispers of love (API) | Déclaration d'Amour |






Legal Notice / General Conditions of Use