Tuesday, 11 October 2011

The NOW() Function

The 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_Id ProductName Unit UnitPrice
1 Jarlsberg 1000 g 10.45
2 Mascarpone 1000 g 32.56
3 Gorgonzola 1000 g 15.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:

ProductName UnitPrice PerDate
Jarlsberg 10.45 10/7/2008 11:25:02 AM
Mascarpone 32.56 10/7/2008 11:25:02 AM
Gorgonzola 15.67 10/7/2008 11:25:02 AM
 

6 comments:

  1. Great goods from you, man. I have understand your stuff previous to
    and you are just extremely wonderful. I really like what you have acquired here,
    certainly like what you're stating and the way in which you say it.
    You make it entertaining and you still care for to keep it sensible.
    I can not wait to read far more from you. This is really a great website.



    Have a look at my webpage - play minecraft free

    ReplyDelete
  2. Hey there! Quick question that's completely off topic.

    Do you know how to make your site mobile friendly? My weblog looks weird when browsing from my iphone4.
    I'm trying to find a template or plugin that might be able to resolve this problem.
    If you have any recommendations, please share. Thanks!


    Here is my web blog quest bars

    ReplyDelete
  3. I'm amazed, I must say. Seldom do I encounter
    a blog that's both educative and entertaining, and let me tell you, you have hit
    the nail on the head. The problem is something which not enough people are speaking
    intelligently about. I am very happy that I found this in my search for something concerning this.

    Quest Bars blogesaurus

    ReplyDelete
  4. Hey I know this is off topic but I was wondering if you knew
    of any widgets I could add to my blog that automatically tweet my newest twitter updates.
    I've been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something like this.
    Please let me know if you run into anything.
    I truly enjoy reading your blog and I look forward to your
    new updates.

    Feel free to surf to my web site :: Diet Plans for Women to Lose Weight

    ReplyDelete
  5. Hello! I realize this is sort of off-topic however I needed to ask.
    Does managing a well-established blog like yours take a lot of work?
    I am brand new to running a blog however I do write in my
    diary on a daily basis. I'd like to start a blog so I can easily
    share my experience and feelings online. Please let me
    know if you have any suggestions or tips for brand new aspiring bloggers.
    Appreciate it!

    Also visit my homepage :: Diet Plans for Women to Lose Weight

    ReplyDelete
  6. Informative article, exactly what I was looking for.

    My blog ... best dating sites

    ReplyDelete