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 ...

Get SQL Pocket Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.