AppLib ADJUST TIMESTAMP

From LucidDB Wiki
Jump to: navigation, search

Contents

Declarations

create or replace function applib.adjust_timestamp(
  stamp timestamp,
  timezone varchar(128),
  gmt_offset int)
returns timestamp
language java
deterministic
no sql
returns null on null input
external name 'applib.applibJar:org.eigenbase.applib.contrib.TimestampUtilUdf.adjustTimestamp';

Syntax

VALUES(APPLIB.ADJUST_TIMESTAMP(timestamp, zoneAdjustmentStr, offsetAmnt));

Purpose

This function provides a way to modify a timestamp's hours or minutes by providing the hour offset directly through gmt_offset or, for finer-grained changing, a string of the format "[+|-]hours:minutes".

Input

  • STAMP: Time to adjust.
  • TIMEZONE: String of the format "[+|-]hours[:minutes]" to use for adjustment instead of gmt_offset.
  • GMT_OFFSET: Positive or negative integer to adjust from the hours of the input time.

Example

0: jdbc:luciddb:> values(applib.adjust_timestamp(timestamp'2011-6-15 22:15:00', '1:3', 2)); 
+----------------------+
|        EXPR$0        |
+----------------------+
| 2011-06-15 23:18:00  |
+----------------------+
0: jdbc:luciddb:> values(applib.adjust_timestamp(timestamp'2011-6-15 22:15:00', '+1:3', 2)); 
+----------------------+
|        EXPR$0        |
+----------------------+
| 2011-06-15 23:18:00  |
+----------------------+
0: jdbc:luciddb:> values(applib.adjust_timestamp(timestamp'2011-6-15 22:15:00', '-1:3', 2)); 
+----------------------+
|        EXPR$0        |
+----------------------+
| 2011-06-15 21:12:00  |
+----------------------+
0: jdbc:luciddb:> values(applib.adjust_timestamp(timestamp'2011-6-15 22:15:00', '+-1:3', 2)); 
+----------------------+
|        EXPR$0        |
+----------------------+
| 2011-06-15 21:12:00  |
+----------------------+
0: jdbc:luciddb:> values(applib.adjust_timestamp(timestamp'2011-6-15 22:15:00', '-+1:3', 2)); 
+----------------------+
|        EXPR$0        |
+----------------------+
| 2011-06-15 23:18:00  |
+----------------------+
0: jdbc:luciddb:> values(applib.adjust_timestamp(timestamp'2011-6-15 22:15:00', '', 2)); 
+----------------------+
|        EXPR$0        |
+----------------------+
| 2011-06-16 00:15:00  |
+----------------------+
0: jdbc:luciddb:> values(applib.adjust_timestamp(timestamp'2011-6-15 22:15:00', '1', 2)); 
+----------------------+
|        EXPR$0        |
+----------------------+
| 2011-06-15 23:15:00  |
+----------------------+
0: jdbc:luciddb:> values(applib.adjust_timestamp(timestamp'2011-6-15 22:15:00', '1:', 2)); 
+----------------------+
|        EXPR$0        |
+----------------------+
| 2011-06-15 23:15:00  |
+----------------------+
0: jdbc:luciddb:> values(applib.adjust_timestamp(timestamp'2011-6-15 22:15:00', '0110', 2)); 
+----------------------+
|        EXPR$0        |
+----------------------+
| 2011-06-15 23:25:00  |
+----------------------+
Product Documentation