Fonctions pour obtenir la date/heure courante

Fonctions pour manipuler les données dans PostgreSQL

Brian Piccolo

Sr. Director, Digital Strategy

Récupérer l'horodatage courant

SELECT NOW();
+-------------------------------+
| now()                         |
|-------------------------------|
| 2019-04-19 02:51:18.448641+00 |
+-------------------------------+
Fonctions pour manipuler les données dans PostgreSQL

Récupérer l'horodatage courant

SELECT NOW()::timestamp;
+----------------------------+
| now()                      |
|----------------------------|
| 2019-04-19 02:51:18.448641 |
+----------------------------+
Fonctions pour manipuler les données dans PostgreSQL

Récupérer l'horodatage courant

Conversion propre à PostgreSQL

SELECT NOW()::timestamp;

Fonction CAST()

SELECT CAST(NOW() as timestamp);
Fonctions pour manipuler les données dans PostgreSQL

Récupérer l'horodatage courant

SELECT CURRENT_TIMESTAMP;
+-------------------------------+
| current_timestamp             |
|-------------------------------|
| 2019-04-19 02:51:18.448641+00 |
+-------------------------------+
Fonctions pour manipuler les données dans PostgreSQL

Récupérer l'horodatage courant

SELECT CURRENT_TIMESTAMP(2);
+-------------------------------+
| current_timestamp             |
|-------------------------------+
| 2019-04-19 02:51:18.44+00     |
+-------------------------------+
Fonctions pour manipuler les données dans PostgreSQL

Date et heure courantes

SELECT CURRENT_DATE;
+--------------+
| current_date |
|--------------|
| 2019-04-19   |
+--------------+
Fonctions pour manipuler les données dans PostgreSQL

Date et heure courantes

SELECT CURRENT_TIME;
+------------------------+
| current_time           |
|------------------------|
| 04:06:30.929845+00:00  |
+------------------------+
Fonctions pour manipuler les données dans PostgreSQL

Passons à la pratique !

Fonctions pour manipuler les données dans PostgreSQL

Preparing Video For Download...