Max Date value

1194 views
Skip to first unread message

Ishaan

unread,
Jan 11, 2011, 3:12:35 AM1/11/11
to mongodb-user
Hi,

What is the max value for Date type supported by Mongo?

db.temporary.insert({ date1: new Date(255555,1,1) }); // Seems to work
db.temporary.insert({ date2: new Date(999999,1,1) }); // Sets date2 to
epoch

Regards,
Ishaan

Nat

unread,
Jan 11, 2011, 3:40:02 AM1/11/11
to mongodb-user
Why would you like to store a date like that? Would it mean anything?
9999 seems to be far enough and seem to be the maximum year supported
by most language due to date-string formatting

Anyway, check out http://objjob.phrogz.net/js/object/224 for your
answer.

Andreas Jung

unread,
Jan 11, 2011, 4:34:37 AM1/11/11
to mongod...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ishaan wrote:

> db.temporary.insert({ date2: new Date(999999,1,1) }); // Sets date2 to

Using year 99999 really does not make sense here.

- -aj
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQGUBAEBAgAGBQJNLCQtAAoJEADcfz7u4AZjVGILvRVi4SAxlLRV/PKWDeDSUMbp
Tm9a5EBls6s/5y+XM7o4xZSvsXR4jkAPOHk0W48TprnttuPdXaRNuUQDFOW8vfob
xlLzXRaG1dfKFaovu0IyYzi5i2S7uh3jEYRbm+RJsye4DMmLz+d3l1TwWQ9p0mN/
c9PAxZL/0CQ2T0EXTnDaxPItoKgoStgmJ5Yqk0l3RLKmI36ZHnX2m+slzm7Eb4lf
aQQLZJy1FgiI4cf3cmoPFo4Q72k65eb3uIye9gUfbcM+2EkDB1iuGr/IvusjUnfo
hHd73CBWZ1dwOnXYOObm28Ivi+Kd2YJJr8D/DhEaf3rskQxAr2l1U3pz0kJ/37Gh
CdNpJjmQgGCmSBPYuR+ogc06GjmtrxKz+xfcPDxMXlhYF392AakcoLx2zvHCEQfm
6TBhGsLMqrLMUBpv0CimCrLoyEJf0kvuADRsbowr5vLJzFlRZA+oua7Yk3F17pAq
WeePZajUxsgY+TYTK43F5EnBLCmRZpM=
=NIT0
-----END PGP SIGNATURE-----

lists.vcf

Robert Stam

unread,
Jan 11, 2011, 10:18:09 AM1/11/11
to mongodb-user
In the BSON document specification DateTimes are stored as a signed 64-
bit number offset (in milliseconds) from the UNIX Epoch
(1970-01-01T00:00:00Z). So the range of dates in BSON is:

Min: 1970-01-01T00:00:00Z - 9,223,372,036,854,775,808 ms
Max: 1970-01-01T00:00:00Z + 9,223,372,036,854,775,807 ms

However, you are more likely going to be limited by the DateTime type
in your programming language of choice. For example, in C# the range
is:

Min: 0001-01-01T00:00:00Z (1970-01-01T00:00:00Z - 62,135,596,800,000
ms)
Max: 9999-12-31T23:59:59.999999Z (1970-01-01T00:00:00Z +
253,402,300,800,000 ms)

So you can see that the range of DateTime values in BSON is much
larger than the range of DateTime values in C# (it's also a bit less
precise since it is measured in milliseconds).

I don't know what the range of Date values in JavaScript is. Perhaps a
JavaScript expert can chime in.

I also agree with the comments that DateTime values that far in the
future or past don't make much sense (in most cases).

On Jan 11, 4:34 am, Andreas Jung <li...@zopyx.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Ishaan wrote:
> > db.temporary.insert({ date2: new Date(999999,1,1) }); // Sets date2 to
>
> Using year 99999 really does not make sense here.
>
> - -aj
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (Darwin)
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org/
>
> iQGUBAEBAgAGBQJNLCQtAAoJEADcfz7u4AZjVGILvRVi4SAxlLRV/PKWDeDSUMbp
> Tm9a5EBls6s/5y+XM7o4xZSvsXR4jkAPOHk0W48TprnttuPdXaRNuUQDFOW8vfob
> xlLzXRaG1dfKFaovu0IyYzi5i2S7uh3jEYRbm+RJsye4DMmLz+d3l1TwWQ9p0mN/
> c9PAxZL/0CQ2T0EXTnDaxPItoKgoStgmJ5Yqk0l3RLKmI36ZHnX2m+slzm7Eb4lf
> aQQLZJy1FgiI4cf3cmoPFo4Q72k65eb3uIye9gUfbcM+2EkDB1iuGr/IvusjUnfo
> hHd73CBWZ1dwOnXYOObm28Ivi+Kd2YJJr8D/DhEaf3rskQxAr2l1U3pz0kJ/37Gh
> CdNpJjmQgGCmSBPYuR+ogc06GjmtrxKz+xfcPDxMXlhYF392AakcoLx2zvHCEQfm
> 6TBhGsLMqrLMUBpv0CimCrLoyEJf0kvuADRsbowr5vLJzFlRZA+oua7Yk3F17pAq
> WeePZajUxsgY+TYTK43F5EnBLCmRZpM=
> =NIT0
> -----END PGP SIGNATURE-----
>
>  lists.vcf
> < 1KViewDownload
Reply all
Reply to author
Forward
0 new messages