Conversion Functions

This page contains the explicit conversion functions supported by e6data.

CAST FUNCTION

CAST( <expr> as <target datatype> )

Converts the input expression to the specified target datatype.

cast('2022-01-11' as date)

The following table contains a matrix of all supported conversions:

Source(Row) Target(Column)varcharinteger/intbigintfloatdoublebooleandatetimestamp

varchar

Y

Y

Y

Y

Y

Y

Y

Y

integer/int

Y

Y

Y

Y

Y

Y

-

-

bigint

Y

Y

Y

-

-

-

-

-

float

Y

Y

-

Y

Y

-

-

-

double

Y

Y

Y

Y

Y

-

-

-

boolean

Y

-

-

-

-

Y

-

-

date

Y

-

-

-

-

-

Y

Y

timestamp

Y

-

-

-

-

-

Y

Y

FORMAT( <format_string>, <value>)

Converts the input expression to the specified target datatype.

This function produces a string in a specific format by utilising the provided format string and arguments.

Support datatype: INT/FLOAT/DOUBLE/STRING/DATE/TIMESTAMP/BOOL

SELECT format('%s%%', 9887);
> 9887%

SELECT format('%.2f', pi());
> 3.14

SELECT format('%,.2f', 167.989);
> 167.99

Usages: We support java format string

TO_DATE( <format_string>, <value>)

This function converts an input expression into a date.

Support datatype: STRING/DATE/TIMESTAMP

select to_date('2024-12-16 12:30:45','yyyy-MM-dd');
> 2024-12-16

SELECT TO_DATE('2024.07.23', 'yyyy.MM.dd');
> 2024-07-23

Usages: we support java format string for format string. However we are not supporting timezone ID and timezone name in the format.

TO_TIMESTAMP( <format_string>, <value>)

This function converts an input expression into a date.

Support datatype: STRING/DATE/TIMESTAMP

SELECT TO_TIMESTAMP('04/13/2024 15:49:03', 'MM/dd/yyyy HH:mm:ss');
> 2024-04-13T15:49:03.000+00:00

SELECT TO_TIMESTAMP('2024.07.23', 'yyyy.MM.dd');
> 2024-07-23T00:00:00.000+00:00

Usages: we support java format string for format string. However we are not supporting timezone ID and timezone name in the format.

Last updated