Skip to content

API Docs - v4.0.6

Time

currentDate (Function)

This function returns system time in yyyy-MM-dd format.

Syntax

<STRING> time:currentDate()

Examples EXAMPLE 1

define stream inputStream (symbol string, price long, volume long);
from inputStream select symbol , time:currentDate() as currentTime 
insert into outputStream;

This query returns symbol from inputStream andcurrent date of the system in yyyy-MM-dd format as current time to the outputStream

currentTime (Function)

This function returns system time in in HH:mm:ss format.

Syntax

<STRING> time:currentTime()

Examples EXAMPLE 1

define stream inputStream (symbol string, price long, volume long);
from inputStream select symbol , time:currentTime() as currentTime
insert into outputStream;

This query returns symbol from inputStream andcurrent time of the system in HH:mm:ss format as current time to the outputStream

currentTimestamp (Function)

This function returns system time in yyyy-MM-dd HH:mm:ss format.

Syntax

<STRING> time:currentTimestamp()

Examples EXAMPLE 1

define stream inputStream (symbol string, price long, volume long);
from inputStream select symbol , time:currentTimestamp() as currentTimestamp
insert into outputStream;

This query returns symbol from inputStream andcurrent time stamp of the system in yyyy-MM-dd HH:mm:ss format as currentTimestamp to the outputStream

date (Function)

This function returns date part from a date or date/time expression.

Syntax

<STRING> time:date(<STRING> date.value, <STRING> date.format)

QUERY PARAMETERS

Name Description Default Value Possible Data Types Optional Dynamic
date.value value of date. eg: "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657". STRING No No
date.format Date format of the provided date value. eg: yyyy-MM-dd HH:mm:ss.SSS yyyy-MM-dd HH:mm:ss.SSS STRING Yes No

Examples EXAMPLE 1

define stream inputStream (symbol string, dateValue string,dateFormat string);
from inputStream
 select symbol,time:date(dateValue,dateFormat) as dateExtracted
 insert into outputStream;

This query extracts the date value from the dateValue which is in format'dateFormat' as the dateExtracted and return symbol, and dateExtracted to the outputStream.

dateAdd (Function)

This function returns added specified time interval to a date.If a STRING parameter passed as the first argument then function accepts four parameters with last as optional which is the date.format. If a LONG parameter passed as the first argument, then function accepts three parameters which are timestamp.in.milliseconds,expr,unit in order.

Syntax

<STRING> time:dateAdd(<STRING> date.value, <INT> expr, <STRING> unit, <STRING> date.format, <LONG> timestamp.in.milliseconds)

QUERY PARAMETERS

Name Description Default Value Possible Data Types Optional Dynamic
date.value value of date. eg: "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657". STRING No No
expr In which amount, selected date format part should be incremented. eg: 2 ,5 ,10 etc. INT No No
unit Which part of the date format you want to manipulate. eg: "MINUTE" , "HOUR" , "MONTH" , "YEAR" , "QUARTER" ,
"WEEK" , "DAY" , "SECOND".
STRING No No
date.format Date format of the provided date value. eg: yyyy-MM-dd HH:mm:ss.SSS yyyy-MM-dd HH:mm:ss.SSS STRING Yes No
timestamp.in.milliseconds date value in milliseconds.(from the epoch) eg: 1415712224000L LONG No No

Examples EXAMPLE 1

define stream inputStream (symbol string,dateValue string,dateFormat string,expr int);
from inputStream
 select symbol , time:dateAdd(dateValue,expr,'YEAR',dateFormat) as yearAdded
insert into outputStream;

This query gets date value from the input stream, adds expr amount to the year value of the date value, format resultant value as date format given in the input stream and finally return the formatted value to the outputStream as yearAdded with the symbol

EXAMPLE 2

define stream inputStream (symbol string,dateValue string,dateFormat string,timestampInMilliseconds long,expr int);
from inputStream
 time:dateAdd(timestampInMilliseconds,expr,'HOUR') as hourAddedMills
 insert into outputStream;

This query gets value of timestampInMilliseconds from the input stream, adds expr amount of hours to it and return resultant value in milliseconds as hourAddedMills into the outputStream with the symbol

dateDiff (Function)

This function returns time(days) between two dates. If two STRING arguments are sent as first two parameters then function should accept four parameters with last two as optional parameters. Parameter order should be dateDiff(date.value1,date.value2,date.format1,date.format2). Else if two LONG arguments are sent as first two parameters then parameter order should be dateDiff(timestamp.in.milliseconds1,timestamp.in.milliseconds2).

Syntax

<INT> time:dateDiff(<STRING> date.value1, <STRING> date.value2, <STRING> date.format1, <STRING> date.format2, <LONG> timestamp.in.milliseconds1, <LONG> timestamp.in.milliseconds2)

QUERY PARAMETERS

Name Description Default Value Possible Data Types Optional Dynamic
date.value1 value of date. eg: "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657". STRING No No
date.value2 value of date. eg: "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657". STRING No No
date.format1 Date format of the provided date.value1. eg: yyyy-MM-dd HH:mm:ss.SSS. yyyy-MM-dd HH:mm:ss.SSS STRING Yes No
date.format2 Date format of the provided date.value2. eg: yyyy-MM-dd HH:mm:ss.SSS. yyyy-MM-dd HH:mm:ss.SSS STRING Yes No
timestamp.in.milliseconds1 date value in milliseconds.(from the epoch) eg: 1415712224000L. LONG No No
timestamp.in.milliseconds2 date value in milliseconds.(from the epoch) eg: 1415712224000L. LONG No No

Examples EXAMPLE 1

define stream inputStream (symbol string,dateValue1 string,dateFormat1 string,dateValue2 string,dateFormat2 string,);
from inputStream
 time:dateDiff(timestampInMilliseconds1,timestampInMilliseconds2)select symbol , time:dateDiff(dateValue1,dateValue2,dateFormat1,dateFormat2) as dateDifference,
 as dateDifferenceInMilliseconds insert into outputStream;

This query return difference between timestampInMilliseconds1 and timestampInMilliseconds2 as dateDifferenceInMilliseconds and difference between dataValue1 which is in the format 'dateFormat1' and dataValue2 which isin the format 'dateFormat2' as dateDifference and return to the outputStream with symbol value

dateFormat (Function)

This function returns a formatted date string.If the first argument is a STRING then function accepts three parameters with last parameter as a optional parameter.Parameter order should be dateFormat(dateValue,dateTargetFormat,dateSourceFormat). Else if first argument is a LONG then function accepts two parameters.Parameter order should be dateFormat(timestampInMilliseconds,dateTargetFormat).

Syntax

<STRING> time:dateFormat(<STRING> date.value, <STRING> date.target.format, <STRING> date.source.format, <LONG> timestamp.in.milliseconds)

QUERY PARAMETERS

Name Description Default Value Possible Data Types Optional Dynamic
date.value value of date. eg: "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657". STRING No No
date.target.format Date format which need to be converted to. eg: yyyy/MM/dd HH:mm:ss. STRING No No
date.source.format Date format of the provided date.value1. eg: yyyy-MM-dd HH:mm:ss.SSS. yyyy-MM-dd HH:mm:ss.SSS STRING Yes No
timestamp.in.milliseconds date value in milliseconds.(from the epoch) eg: 1415712224000L. LONG No No

Examples EXAMPLE 1

define stream inputStream (symbol string,dateValue string,sourceFormat string,timestampInMilliseconds long,targetFormat string);
from inputStream
select symboltime:dateFormat(dateValue,targetFormat,sourceFormat) as formattedDate,time:dateFormat(timestampInMilliseconds,targetFormat) as formattedUnixDate
insert into outputStream;

This query formats the dateValue in the inputStream which is currently in sourceFormat to the targetFormat as formattedData and formats timestampInMilliseconds which is in millisecond to the targetFormat as formattedUnixDate then return symbol formattedDate and formattedUnixDate to the outputStream.

dateSub (Function)

This function returns subtracted specified time interval to a date. If a STRING parameter passed as the first argument then function accepts four parameters with last as optional which is the date.format. If a LONG parameter passed as the first argument, then function accepts three parameters which are timestamp.in.milliseconds,expr,unit in order.

Syntax

<STRING> time:dateSub(<STRING> date.value, <INT> expr, <STRING> unit, <STRING> date.format, <LONG> timestamp.in.milliseconds)

QUERY PARAMETERS

Name Description Default Value Possible Data Types Optional Dynamic
date.value value of date. eg: "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657". STRING No No
expr In which amount, selected date format part should be incremented. eg: 2 ,5 ,10 etc. INT No No
unit Which part of the date format you want to manipulate. eg: "MINUTE" , "HOUR" , "MONTH" , "YEAR" , "QUARTER" ,
"WEEK" , "DAY" , "SECOND".
STRING No No
date.format Date format of the provided date value. eg: yyyy-MM-dd HH:mm:ss.SSS yyyy-MM-dd HH:mm:ss.SSS STRING Yes No
timestamp.in.milliseconds date value in milliseconds.(from the epoch) eg: 1415712224000L LONG No No

Examples EXAMPLE 1

define stream inputStream (symbol string,dateValue string,dateFormat string,expr int);
from inputStream
 select symbol , time:dateAdd(dateValue,expr,'YEAR',dateFormat) as yearSubtracted
insert into outputStream;

This query gets date value from the input stream, subtract expr amount from the year value of the date value, format resultant value as date format given in the input stream and finally return the formatted value to the outputStream as yearSubtracted with the symbol

EXAMPLE 2

define stream inputStream (symbol string,dateValue string,dateFormat string,timestampInMilliseconds long,expr int);
from inputStream
 time:dateSub(timestampInMilliseconds,expr,'HOUR') as hourSubtractedMills
 insert into outputStream;

This query gets value of timestampInMilliseconds from the input stream, subtract expr amount of hours from it and return resultant value in milliseconds as hourSubtractedMills into the outputStream with the symbol

dayOfWeek (Function)

This function returns the day on which a given date falls.

Syntax

<STRING> time:dayOfWeek(<STRING> date.value, <STRING> date.format)

QUERY PARAMETERS

Name Description Default Value Possible Data Types Optional Dynamic
date.value value of date. eg: "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657". STRING No No
date.format Date format of the provided date value. eg: yyyy-MM-dd HH:mm:ss.SSS yyyy-MM-dd HH:mm:ss.SSS STRING Yes No

Examples EXAMPLE 1

define stream inputStream (symbol string, dateValue string,dateFormat string);
from inputStream
select symbol,time:dayOfWeek(dateValue,dateFormat) as dayOfWeekExtracted
insert into outputStream;

The Query extract the day of the week from the date given as dateValue which isin the format 'dateFormat' and return symbol and extracted day as dayOfWeekExtractedto the outputStream.

extract (Function)

This function returns date attributes from a date expression. If the first argument passed is a STRING then the function will accept three arguments with last parameter as optional which is date.format.Parameter order should be extract(unit,date.value,date.format). Else if the first argument passed is a LONG then function accepts two parameters.Parameter order is extract(timestamp.in.milliseconds,unit).

Syntax

<INT> time:extract(<STRING> unit, <STRING> date.value, <STRING> date.format, <LONG> timestamp.in.milliseconds)

QUERY PARAMETERS

Name Description Default Value Possible Data Types Optional Dynamic
unit Which part of the date format you want to manipulate. eg: "MINUTE" , "HOUR" , "MONTH" , "YEAR" , "QUARTER" ,
"WEEK" , "DAY" , "SECOND".
STRING No No
date.value value of date. eg: "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657". STRING No No
date.format Date format of the provided date value. eg: yyyy-MM-dd HH:mm:ss.SSS yyyy-MM-dd HH:mm:ss.SSS STRING Yes No
timestamp.in.milliseconds date value in milliseconds.(from the epoch) eg: 1415712224000L LONG No No

Examples EXAMPLE 1

define stream inputStream (symbol string,dateValue string,dateFormat string,timestampInMilliseconds long);
from inputStream 
select symbol, time:extract('YEAR',dateValue,dateFormat) as YEAR,time:extract(timestampInMilliseconds,'HOUR') as HOUR
 insert into outputStream;

This query extracts the year value from the dateValue which is in format'dateFormat' as the YEAR, hours from timestampInMilliseconds as HOUR and return symbol, YEAR and HOUR to the outputStream.

timestampInMilliseconds (Function)

This function returns system time or given time in milliseconds.If two STRING parameters are sent as the first argument, the parameter order should be timestampInMilliseconds(date.value,date.format) with last parameter as the optional parameter with is date.format.Else if no argument method invoked then system time will be returned in milliseconds.

Syntax

<LONG> time:timestampInMilliseconds(<STRING> date.value, <STRING> date.format)

QUERY PARAMETERS

Name Description Default Value Possible Data Types Optional Dynamic
date.value value of date. eg: "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657". STRING No No
date.format Date format of the provided date value. eg: yyyy-MM-dd HH:mm:ss.SSS yyyy-MM-dd HH:mm:ss.SSS STRING Yes No

Examples EXAMPLE 1

define stream inputStream (symbol string, price long, volume long);
from inputStream
select symbol , time:timestampInMilliseconds('2007-11-30 10:30:19','yyyy-MM-DD HH:MM:SS') as timestampInMilliseconds
insert into outputStream;

The query convert the 2007-11-30 10:30:19 which is in yyyy-MM-DD HH:MM:SS format to the milliseconds as timestampInMilliseconds and return symbol and timestampInMilliseconds to the output stream

EXAMPLE 2

define stream inputStream (symbol string, price long, volume long);
from inputStream
select symbol , time:timestampInMilliseconds()as timestampInMilliseconds
insert into outputStream;

The query get the system time in milliseconds as timestampInMilliseconds and return symbol and timestampInMilliseconds to the output stream

utcTimestamp (Function)

This function returns System time in yyyy-MM-dd HH:mm:ss format

Syntax

<STRING> time:utcTimestamp()

Examples EXAMPLE 1

define stream inputStream (symbol string, price long, volume long);from inputStream select symbol , time:utcTimestamp() as utcTimestamp insert into outputStream;

The query return symbol from the inputStream and system time stamp in yyyy-MM-dd HH:mm:ss format as utcTimestamp to the outputStream.