O'Reilly logo

SQL Pocket Guide, 2nd Edition by Jonathan Gennick

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Functions

The following sections describe some of the more useful scalar functions, which return one value per row when invoked from a SQL statement. Conversion functions are described earlier in the "Dataype Conversion" section. Aggregate functions, which combine values from many rows into one result, are described later in "Grouping and Summarizing." Window functions, which return aggregate values in detail rows, are described later in the "Window Functions" section.

Note

MySQL requires the leading parenthesis of the argument list to immediately follow a function's name. For example, UPPER (name) will generate an error message because of the space between UPPER and (name).

Datetime Functions (Oracle)

Oracle implements a wide variety of helpful functions for working with dates and times.

Getting the current date and time in Oracle

It's common to need the current date and/or time of day. SYSDATE is often used for that purpose:

SELECT SYSDATE FROM dual;

2006-02-07 09:32:32.0

You can use ALTER SESSION to specify a default date format for your session using the date format elements described earlier in Table 1.

ALTER SESSION
   SET NLS_DATE_FORMAT = 'dd-Mon-yyyy hh: mi:ss';

Following is a complete list of Oracle functions to return current datetime information:

CURRENT_DATE

Returns the current date in the session time zone as a value of type DATE.

CURRENT_TIMESTAMP[( precision )]

Returns the current date and time in the session time zone as a value of type TIMESTAMP WITH TIME ZONE. The precision ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required