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(1463284740000, '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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -