cassandra extract month from timestamp -


in postgres, have function extract month, year etc timestamp using extract function. see below.

select extract(month timestamp '2001-02-16 20:38:40'); 

is possible same in cassandra? there function this?

if possible, can run queries such find entries in year "2015" , month "may". possible in postgres using extract function.

in cassandra handle little differently. can have fields in table of type timestamp or timeuuid, , use field in time range query.

for example if wanted entries 2015 , may , have timestamp field called 'date', query this:

select * mytable date > '2015-05-01' , date < '2015-06-01' allow filtering; 

you can use number of different formats specifying date specify time more precisely (such down fractions of seconds).

cassandra converts date strings using org.apache.commons.lang3.time.dateutils class, , allows following date formats:

private static final string[] datestringpatterns = new string[] {         "yyyy-mm-dd hh:mm",         "yyyy-mm-dd hh:mm:ss",         "yyyy-mm-dd hh:mmx",         "yyyy-mm-dd hh:mmxx",         "yyyy-mm-dd hh:mmxxx",         "yyyy-mm-dd hh:mm:ssx",         "yyyy-mm-dd hh:mm:ssxx",         "yyyy-mm-dd hh:mm:ssxxx",         "yyyy-mm-dd hh:mm:ss.sss",         "yyyy-mm-dd hh:mm:ss.sssx",         "yyyy-mm-dd hh:mm:ss.sssxx",         "yyyy-mm-dd hh:mm:ss.sssxxx",         "yyyy-mm-dd't'hh:mm",         "yyyy-mm-dd't'hh:mmx",         "yyyy-mm-dd't'hh:mmxx",         "yyyy-mm-dd't'hh:mmxxx",         "yyyy-mm-dd't'hh:mm:ss",         "yyyy-mm-dd't'hh:mm:ssx",         "yyyy-mm-dd't'hh:mm:ssxx",         "yyyy-mm-dd't'hh:mm:ssxxx",         "yyyy-mm-dd't'hh:mm:ss.sss",         "yyyy-mm-dd't'hh:mm:ss.sssx",         "yyyy-mm-dd't'hh:mm:ss.sssxx",         "yyyy-mm-dd't'hh:mm:ss.sssxxx",         "yyyy-mm-dd",         "yyyy-mm-ddx",         "yyyy-mm-ddxx",         "yyyy-mm-ddxxx" }; 

but note cassandra not @ ad hoc queries relational database postgres. typically set table schema group time ranges wanted query separate partitions within table.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -