
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Converting isodate to numerical value in MongoDB?
You can use getTime() for this. Following is the syntax −
yourVariableName.getTime();
Convert ISODate to numerical value −
> var arrivalDate=ISODate('2019-04-18 13:50:45');
Following is the query to convert ISODate to numerical value −
> arrivalDate.getTime();
This will produce the following output −
1555595445000
Let us verify that it is a correct numerical value for ISODate or not. Following is the query to get correct ISODate whenever we apply above numeric value −
> new Date(1555595445000);
This will produce the following output −
ISODate("2019-04-18T13:50:45Z")
Yes, this is a correct ISODate.
- Related Questions & Answers
- Get component of Date / ISODate in MongoDB?
- How to work Date query with ISODate in MongoDB?
- Fetch month, day, year, etc. from ISODate in MongoDB?
- Converting string to date in MongoDB?
- MongoDB query to fetch date records (ISODate format) in a range
- How to convert string to numerical values in MongoDB?
- How to find minimum value in MongoDB?
- How to print NumberLong value in MongoDB?
- Extract subarray value in MongoDB?
- Count distinct value in MongoDB?
- Querying null value in MongoDB?
- Calculate average value in MongoDB
- MongoDB query to replace value in an array?
- How to print document value in MongoDB shell?
- How to pop a single value in MongoDB?
Advertisements