SQL NOW() Function

The NOW() function returns the current system date and time.
SQL NOW() Syntax
SELECT NOW() FROM table_name
SQL NOW() Example
We have the following "Products" table:
Prod_IdProductNameUnitUnitPrice
1Jarlsberg1000 g10.45
2Mascarpone1000 g32.56
3Gorgonzola1000 g15.67

Now we want to display the products and prices per today's date.

We use the following SELECT statement:

SELECT ProductName, UnitPrice, Now() as PerDate FROM Products
The result-set will look like this:
ProductNameUnitPricePerDate
Jarlsberg10.4510/7/2008 11:25:02 AM
Mascarpone32.5610/7/2008 11:25:02 AM
Gorgonzola15.6710/7/2008 11:25:02 AM

No comments: