Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • what is the use of NOW() function in SQL?

    • 0
    • 1
    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 342
    Comment on it

    In SQL, NOW() function is used to return the current system date and time.

    NOW() Syntax

    SELECT NOW() FROM table_name;
    

    We have a table "employee" as below:

        employee
        id  first_name            last_name       salary
        .......................................................
        1   John                     Simp         10000
        2   Chris                    Hely         25000
        3   Joy                      Roy          20000
        4   Jenny                    Mill         35000
    

    NOW() Example

    The below query selects the first_name and salary for today from the "employee" table:

    SELECT first_name,salary,NOW() as current_date FROM employee;
    

    Result:

        first_name            salary        current_date
        .......................................................
        John                  10000            1/1/2016 8:51:25 AM
        Chris                 25000            1/1/2016 8:51:25 AM
        Joy                   20000            1/1/2016 8:51:25 AM
        Jenny                 35000            1/1/2016 8:51:25 AM
    

    Hope this will help you :)

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: