Hi guys.
I have 2 queries where i find very hard to convert them to mongodb type language.
The first one is this:
cursor=execute("select date_trunc('day',timestamp1) as day,avg(id13) from timestamppsql where timestamp1 >='2010-01-01 00:05:00' and timestamp1<='2011-01-01 00:05:00' group by day")
And the second one is this:
cursor=execute("select date_trunc('hour',timestamp1) as hour,avg(id13) from timestamppsql where timestamp1 >='2010-01-01 00:05:00' and timestamp1<='2010-01-01 10:05:00' group by hour order by hour desc")
I cant find out whats the equivalent date_trunc in mongodb.Any help would be very much appreciated.Thanks in advance!
You are receiving the error documents must have only string keys, key was <built-in function format> because you are missing quotes around the format field.
Also you don’t need to have the “null” id. You only need that if you are creating a total for all documents.