n1ql - Couchbase convert epoch to ISO -
i'm struggling convert epoch iso datetime couchbase n1ql. couchbase stores etoch time milliseconds , need full iso8 format yyy-mm-ddthh:mm:ss.s. have tried:
select date_part_millis(1463284740000, 'year'), date_part_millis(1463284740000, 'month'), date_part_millis(1463284740000, 'day')
but returns json-like response. tries concatenate select date_part_millis(1463284740000, 'year') || date_part_millis(1463284740000, 'month') || date_part_millis(146328474000
0, 'day')
but renders nothing back
[ { "$1": null } ]
any suggestion?
in couchbase can store time number (in milliseconds) or string iso-8601 format. provides many date functions work on iso-8601 format described @ https://developer.couchbase.com/documentation/server/current/n1ql/n1ql-language-reference/datefun.html
select millis_to_str(1463284740000);
date_part_millis(date1, part [, tz]) extracts value of given date component epoch/unix timestamp value. return value -- integer representing value of component extracted timestamp. string concatenation expects string, add tostring around function like
select tostring(date_part_millis(1463284740000, 'year')) || "-" || tostring(date_part_millis(1463284740000, 'month')) || "-" || to_string(date_part_millis(1463284740000, 'day'));
Comments
Post a Comment