Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
330 views
in Technique[技术] by (71.8m points)

database - how to query between time in Date field in MongoDB

I have searched a lot but could not find any specific example related to this problem, so I am posting this question. I have data in CSV format that I load in MongoDB compass. It has a DateTime field of type Date and user field of type int and also calories field of type double. What I want to do is.

I want to query the average calories during morning, evening, and night in a specific month but could not write the right query.

I want to aggregate the data for all the attributes by time intervals into the morning, day, night, and store this data in the database. That means that I have to split the data into 3 sections: 7 am-12:pm, 12:01-7:00 pm and 7:01pm-6:59am. Get the averages of these values between these times for each attribute and store the data in the database.

Here is an image of data

Thanks all.

question from:https://stackoverflow.com/questions/65884867/how-to-query-between-time-in-date-field-in-mongodb

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...