Friday 14 April 2017

findOne query compare date in utc

I am using UTC date format in my application and storing the data as shown below

{ 
"_id" : ObjectId("58ef69c221f24305c0c7123b"), 
"departmentId" : "58db361424f6bc2d3840f38b", 
"departmentOfficerId" : "58e21f0a7fa219021cd351ca", 
"departmentOfficerCurrentMonth" : NumberInt(1), 
"calenderYear": 2017 
"createdAt" : "Thu, 13 Apr 2017 12:06:26 GMT", 
"updatedAt" : "Thu, 13 Apr 2017 12:06:26 GMT", 
}

It should not give me any data but it gives me whole data.

and I am using the following mongodb query

db.departmentOfficerMonthlyScores.findOne(
{ 
 departmentOfficerId: "58e21f0a7fa219021cd351ca",
 departmentOfficerCurrentMonth: 1,
 calenderYear: 2017, 
 updatedAt: { "$gte" : "Fri, 14 Apr 2017 06:33:10 GMT" } 
}
)

but when I am using this query where in the date provided for comparing is on the same day

db.departmentOfficerMonthlyScores.findOne(
{ 
 departmentOfficerId: "58e21f0a7fa219021cd351ca",
 departmentOfficerCurrentMonth: 1,
 calenderYear: 2017, 
 updatedAt: { "$gte" : "Thu, 13 Apr 2017 13:16:20 GMT" } 
}
)

It is giving me correct result i.e null. How to handle this



via akash

No comments:

Post a Comment