Summing over range of date fields


#1

Hey, i’m new to CB and trying to move from MySQL…
I’ve moved a MySQL table to CB by making each MySQL row as a CB doc. (not sure yet if that the most effective data model for me… but i’m still testing it).
Every document of mine has a date field in the following format:
“Dec 23, 2015 12:00:00 AM”,
Most of my queries on MySQL include several different sum operations over many rows (documents) on different fields according to range of dates…
Is it possible to do the same here using the following date format? Or, do i need to convert the date to numerical date over all the documents… if the later is the solution, how do iterate over all docs to change the the date format to all of them? (I’m Using java)


#2

Hi, we do advise that you store all dates as numbers. There are several function with N1QL that might help you change these dates. Please take a look at http://developer.couchbase.com/documentation/server/4.1/n1ql/n1ql-language-reference/datefun.html


#3

Hey, Thanks for the response.
I’ve seen the page you’ve attached. But, all functions there relate to the supported formats… and my format isn’t one of those supported formats… In addition is there a way to update ALL documents in my bucket to the new date format?