Abh
Abh

Reputation: 105

what is the best way to use datetime in mongoDB

I am parsing nginx log and I want to store date and time from my logs to mongodb..I am storing date as string(in this format yyyy-mm-dd) in my database and my programming language is perl.What is the best effective way to store date..should I use perl datetime module to format date like this ""date" : "Sun Feb 13 2011 05:30:00 GMT+0530 (IST)""

I really want to understand what is the best way to store date in mongodb.Please guide me

Upvotes: 4

Views: 2377

Answers (1)

Andrew Orsich
Andrew Orsich

Reputation: 53685

I suppose that for logs better to story date as date but not as string, because with string you will not able query for logs from one date to another(range). I suppose that you will use range queries more than others.

Upvotes: 3

Related Questions