SQL NOW () Fonction
La fonction NOW ()
La fonction Now () renvoie la date et l'heure du système.
SQL NOW () Syntaxe
SELECT NOW() FROM table_name
SQL NOW () Exemple
Nous avons ce qui suit table "Produits":
| Prod_id | ProductName | Unité | UnitPrice |
|---|---|---|---|
| 1 | Jarlsberg | 1000 g | 10,45 |
| 2 | Mascarpone | 1000 g | 32,56 |
| 3 | Gorgonzola | 1000 g | 15,67 |
Maintenant, nous voulons afficher les produits et les prix par date d'aujourd'hui.
On utilise l'instruction SELECT suivante:
SELECT ProductName, UnitPrice, Now() as PerDate FROM Products
L'ensemble de résultats se présente comme suit:
| ProductName | UnitPrice | PerDate |
|---|---|---|
| Jarlsberg | 10,45 | 07/10/2008 11:25:02 |
| Mascarpone | 32,56 | 07/10/2008 11:25:02 |
| Gorgonzola | 15,67 | 07/10/2008 11:25:02 |

0 commentaires:
Post a Comment
HELLO VISITORS THANKS FOR YOUR VISIT AND COMMENT