Skip to content

API Docs - v4.1.0

Time

currentDate (Function)

This function returns the 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 the 'InputStream' and the current date and time, to the 'OutputStream'.It returns the current date in the 'yyyy-MM-dd' format.

currentTime (Function)

This function returns system time in the '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, the symbol from the 'InputStream' andthe current time of the system in 'HH:mm:ss' format as current time,to the 'OutputStream'.

currentTimestamp (Function)

This function returns the 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 the 'InputStream' and the current time stamp of the system in 'yyyy-MM-dd HH:mm:ss' format as 'currentTimestamp', to the 'OutputStream'.

date (Function)

This function returns the date part of 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 The value of the date. For example, "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657". STRING No No
date.format The date format of the date value provided. For example, '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 'dateValue' in the 'dateFormat' format as the 'dateExtracted'. The query then returns the symbol and the 'dateExtracted' to the 'OutputStream'.

dateAdd (Function)

This function returns the specified time interval added to a date.If a parameter of 'STRING' type is passed as the first argument, the function accepts four parameters with the last parameter, i.e., 'dateFormat', as an optional one. If a parameter of 'LONG' type is passed as the first argument, the function accepts three parameters, i.e., 'timestampInMilliseconds', 'expr' and 'unit' in the given 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 The value of the date.For example, "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657". STRING No No
expr This is the amount by which the selected part of the date should be incremented.For example, 2 ,5 ,10, etc. INT No No
unit This is the part of the date that needs to be modified.For example, "MINUTE" , "HOUR" , "MONTH" , "YEAR" , "QUARTER" ,
"WEEK" , "DAY" , "SECOND".
STRING No No
date.format The format of the date value provided. For example, 'yyyy-MM-dd HH:mm:ss.SSS'. yyyy-MM-dd HH:mm:ss.SSS STRING Yes No
timestamp.in.milliseconds The date value in milliseconds from the epoch. For example, 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 the date value from the 'InputStream, increments the 'YEAR' value of it by the 'expr' value given, formats the resultant value into the 'dateFormat' format given in the input stream and returns 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 the value of the 'timestampInMilliseconds' attribute from the input stream, adds the 'expr' number of hours to it and returns the resultant value in milliseconds as 'hourAddedMills', into the 'OutputStream' with the symbol.

dateDiff (Function)

This function returns the time in days, between two dates. Two arguments of 'String' type are sent as the first two parameters. The function can accept four parameters,the last two parameters corresponding to the date formats being optional ones. The order of the parameters should be dateDiff(date.value1,date.value2,date.format1,date.format2). Instead, if two arguments of 'Long' type are sent as the first two parameters, the order of the parameters 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 The date value of the first parameter. For example, "2014-11-11 13:23:44.657", "2014-11-11", "13:23:44.657". STRING No No
date.value2 The date value of the second parameter. For example, "2014-11-11 13:23:44.657", "2014-11-11", "13:23:44.657". STRING No No
date.format1 The format of the date provided for the first parameter, i.e., yyyy-MM-dd HH:mm:ss.SSS. yyyy-MM-dd HH:mm:ss.SSS STRING Yes No
date.format2 The format of the date provided for the second parameter, i.e., yyyy-MM-dd HH:mm:ss.SSS. yyyy-MM-dd HH:mm:ss.SSS STRING Yes No
timestamp.in.milliseconds1 The date value in milliseconds from the epoch. For example, 1415712224000L. LONG No No
timestamp.in.milliseconds2 The date value in milliseconds from the epoch. For example, 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 returns the difference between 'timestampInMilliseconds1' and 'timestampInMilliseconds2' as the 'dateDifferenceInMilliseconds' and the difference between 'dataValue1' which is in the format, 'dateFormat1' and 'dataValue2' which is in the format, 'dateFormat2', as 'dateDifference'. This function then redirects the results to the 'OutputStream'.

dateFormat (Function)

This function returns a formatted date string.If the first argument is of 'String' type, then the function accepts three parameters with the last parameter as an optional parameter.The order of the parameters should be dateFormat(dateValue,dateTargetFormat,dateSourceFormat). Instead, if the first argument is of 'Long' type, then it accepts two parameters.In this case, the order of the parameter 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 The value of the date. For example, "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657". STRING No No
date.target.format The format of the date into which the date value needs to be converted. For example, 'yyyy/MM/dd HH:mm:ss'. STRING No No
date.source.format The format in which the data value is present in the input stream.For example, 'yyyy-MM-dd HH:mm:ss.SSS'. yyyy-MM-dd HH:mm:ss.SSS STRING Yes No
timestamp.in.milliseconds The date value in milliseconds from the epoch. For example, 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 in the 'sourceFormat' to the 'targetFormat' as 'formattedData'. It also formats 'timestampInMilliseconds' which is in milliseconds to the 'targetFormat' as 'formattedUnixDate'. The function then returns the symbol 'formattedDate' and 'formattedUnixDate' to the 'OutputStream'.

dateSub (Function)

This function returns the date after subtracting a specified time interval from it. If a parameter of 'String' type is passed as the first argument, then the function accepts four parameters with the last parameter, i.e., 'date.format' as an optional one.If a parameter of 'Long' type is passed as the first argument, then the function accepts three parameters, i.e., 'timestamp.in.milliseconds', 'expr' and 'unit' in the given 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 The value of date. For example, "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657". STRING No No
expr The amount by which the selected part of the date should be incremented. For example, 2 ,5 ,10, etc. INT No No
unit The part of the date that is required to be modified. For example, "MINUTE" , "HOUR" , "MONTH" , "YEAR" , "QUARTER" ,
"WEEK" , "DAY" , "SECOND".
STRING No No
date.format The date format of the date value provided. For example, 'yyyy-MM-dd HH:mm:ss.SSS' yyyy-MM-dd HH:mm:ss.SSS STRING Yes No
timestamp.in.milliseconds The date value in milliseconds from the epoch. For example, 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 the date value from the input stream, decrements the 'YEAR'value of the 'dateValue' by the 'expr' value given, formats the resultant value into the 'dateFormat' format in the input stream and returns 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 the value of the 'timestampInMilliseconds' from the input stream, subtracts the 'expr' number of hours from it and returns the resultant value in milliseconds as 'hourSubtractedMills', to 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 The value of the date. For example, "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657". STRING No No
date.format The date format of the date value provided. For example, '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 extracts the day on which the date given as 'dateValue' in the 'dateFormat' format falls. It returns the symbol and the extracted day as 'dayOfWeekExtracted', to the 'OutputStream'.

extract (Function)

This function returns date attributes from a date expression. If the first argument passed is of 'String' type then the function accepts three arguments with the last parameter, i.e., 'date.format' as an optional one. The order of the parameter is extract(unit,date.value,date.format). Instead, if the first argument passed is of 'Long' type, then the function accepts two parameters.In this case, the 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 The part of the date that needs to be manipulated. For example, "MINUTE", "HOUR", "MONTH", "YEAR", "QUARTER",
"WEEK", "DAY", "SECOND".
STRING No No
date.value The value of date. For example, "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657". STRING No No
date.format The date format of the date value provided. For example, 'yyyy-MM-dd HH:mm:ss.SSS'. yyyy-MM-dd HH:mm:ss.SSS STRING Yes No
timestamp.in.milliseconds The date value in milliseconds from the epoch. For example, 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' as 'YEAR'. The 'dateValue' is in the 'dateFormat' format. It also extracts the hours from 'timestampInMilliseconds' as 'HOUR'. The query then returns the symbols, 'YEAR' and 'HOUR' to the 'OutputStream'.

timestampInMilliseconds (Function)

This function returns the system time or given time in milliseconds.If two parameters of 'String' type are sent as the first argument, the order of the parameters should be timestampInMilliseconds(date.value,date.format) with the last parameter, i.e., 'date.format', as the optional oneInstead, if no argument method is invoked, the system time is 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 The value of the date. For example, "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657". STRING No No
date.format The date format of the date value provided. For example, '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 converts 2007-11-30 10:30:19 which is in 'yyyy-MM-DD HH:MM:SS' format to milliseconds as 'timestampInMilliseconds' and returns the symbol and 'timestampInMilliseconds' to the 'OutputStream'.

EXAMPLE 2

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

The query gets the system time in milliseconds as 'timestampInMilliseconds' and returns the symbol from the 'InputStream' and 'timestampInMilliseconds' to the 'OutputStream'.

utcTimestamp (Function)

This function returns the 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 returns the symbol in the 'InputStream', and the system time stamp in 'yyyy-MM-dd HH:mm:ss' format as 'utcTimestamp', to the 'OutputStream'.