This is an old revision of the document!


DRAFT

Omnidex SQL Function: $COMPARE_DATE

Description

The $COMPARE_DATES function determines the interval between two dates and returns that value as a fractional floating point value. The interval will default to days unless overridden using the unit parameter.

Syntax

$COMPARE_DATES ( <date_column1 | 'date_string1' > , < date_column2 | 'date_string2 > 
    [, [date_unit] 
    [, options]
    )

Discussion

< date_column1 | 'date_string1' >

An expression resulting in a date-class or string-class datatype

< date_column2 | 'date_string2' >

An expression resulting in a date-class or string-class datatype

date_unit

A string containing a unit abbreviation identifying the type of interval. The supported abbreviations are the same as those found in the EXTRACT function.

Valid date_unit options:

Date_unit Description
YEAR Year
MONTH Month
DAY Day
HOUR Hour
MINUTE Minute
SECOND Second
A Lowercase am/pm indicator
AA Uppercase AM/PM indicator
D Non-zero-filled day-of-month (1, 2, 3)
0D Zero-filled day-of-month (01, 02, 03)
DD Day of year (44)
0DD Zero-filled day of year (044)
F Non-zero-filled fraction of a second (1, 2)
0F Zero-filled fraction of a second (01, 02)
H 12-hour, non-zero-filled hour of day (12, 1)
0H 12-hour, zero-filled hour of day (12, 01)
HH 24-hour, non-zero-filled hour of day (24, 1)
0HH 24-hour, zero-filled hour of day (24, 01)
J Non-zero-filled Julian date (1, 2)
0J Zero-filled Julian date (01, 02)
M Non-zero-filled month number (1-January, 2-February)
0M Zero-filled day-of-month number (01-January, 02-February)
MM Three-character month abbreviation (Jan, Feb)
MMM Fully spelled month (January, February)
N Non-zero-filled minute of hour (1, 2)
0N Zero-filled minute of hour (01, 02)
Q Quarter of the year (1)
QQ Quarter of the year abbreviation (Q1)
QQQ Quarter of the year name (First Quarter)
S Non-zero-filled second of minute (1, 2)
0S Zero-filled second of minute (01, 02)
W Day of the week number (1-Sunday, 2-Monday)
WW Three-character day-of-week abbreviation (Sun, Mon)
WWW Fully spelled day-of-week (Sunday, Monday)
YY Two-digit year (99, 00)
YYYY Four-digit year (1999, 2000)
options

A string containing options for this functions. No options exist at this time.

The result of the $COMPARE_DATES function is an INTEGER datatype reflecting the number of units between the two dates.

Example

Example 1

> select $compare_date('20090101', current_date, 'DD') from $omnidex

$COMPARE_DA
-----------
        462
 
Back to top
dev/sql/functions/compare_dates.1270758959.txt.gz ยท Last modified: 2016/06/28 22:38 (external edit)