当前位置:Gxlcms > 数据库问题 > Mongodb按照日期分组统计

Mongodb按照日期分组统计

时间:2021-07-01 10:21:17 帮助过:23人阅读

或者

Aggregation.project().and(DateOperators.DateToString.dateOf("createTime").toString("%Y-%m-%d")).as("name"),
Aggregation.group("time").count().as("count")

dateAsFormattedString()方法会默认将当前时间转为系统默认的时区

2.进行时间补偿(默认当前时区是东八区,即8x3600x1000=28800000)

Aggregation.project().andExpression("add(createTime,28800000)").as("time"),
Aggregation.group("time").count().as("count")

Mongodb按照日期分组统计

标签:mon   tor   operator   str   pre   god   ssi   lis   count   

人气教程排行