In order to return or fetch the current date and time of the system, the NOW() function is used.

 

SQL NOW() Syntax is as follows:

Select Now()

From table_name;

 

Let us consider the below Students table:

roll_no

Name

total_marks

(out of 600)

percentage

grade

1

Ashok

392

65.33

B

2

Chaitali

454

75.67

A

3

Smriti

502

83.60

A

4

Kaushik

337

56.10

C

 

Example:

The following SQL statement selects the name and total marks for today from the Students table:

Select name, total_marks, Now()

From Students;

 

The result will be as follows:

Name

total_marks

(out of 600)

Date and Time

Ashok

392

11/27/2014 11.18.44PM

Chaitali

454

11/27/2014 11.18.44PM

Smriti

502

11/27/2014 11.18.44PM

Kaushik

337

11/27/2014 11.18.44PM