This article presents 5 ways to return the seconds portion from a Date object in MongoDB.
Continue readingTag: dates
5 Ways to Get the Minutes from a Date in MongoDB
This article presents 5 ways to return the minutes portion from a Date object in MongoDB.
Continue reading5 Ways to Get the Hour from a Date in MongoDB
MongoDB provides a good range of aggregation pipeline operators for working with dates, including operators that extract certain parts of dates, such as the year, month, day, hours, minutes, etc.
There are also a couple of MongoDB methods that enable you to iterate through a cursor, and apply a JavaScript function. You can therefore use JavaScript to extract date values and date parts, etc from a field as required.
This article presents 5 ways to return the hour portion from a Date object in MongoDB.
Continue readingFormat sysjobhistory datetime & duration Columns in SQL Server
If you’ve ever queried the sysjobhistory
table in the msdb
database, you’ll probably know that the datetime and duration columns are stored as integers.
In particular, when you query this table, the run_date
, run_time
, and duration
columns are returned as integers, which can make it difficult to read.
Below is a query you can use to return this data in an easier to read format.
Continue reading3 Ways to Get the Week from a Date in MongoDB
MongoDB provides various options for extracting date parts from a date.
This article presents 3 ways to return the week portion from a date in MongoDB.
Continue reading8 Ways to Get the Day from a Date in MongoDB
When extracting the day from a date, the exact option we use will depend on how we want the day to be represented.
For example, do we want the day of the week, the day of the month, or the day of the year? Or perhaps we want it in ISO 8601 format? The return value will usually be different depending on which one we choose.
This article explores those options, and therefore presents 8 ways to return the day portion from a date in MongoDB.
Continue reading5 Ways to Get the Month from a Date in MongoDB
MongoDB provides a number of aggregation pipeline operators for working with dates, including operators that extract certain parts of dates, such as the year, month, day, etc.
There are also a couple of MongoDB methods that enable you to iterate through a cursor, and apply a JavaScript function. You can therefore use JavaScript to extract date values and date parts, etc from a field as required.
This article presents 5 ways to return the month portion from a date in MongoDB.
Continue reading6 Ways to Get the Year from a Date in MongoDB
MongoDB provides quite a few aggregation pipeline operators for working with dates. This includes operators that extract certain parts of dates, such as the year, month, day, etc.
There are also a couple of MongoDB methods that enable you to iterate through a cursor, and apply a JavaScript function. This therefore allows you to use JavaScript to extract date values and date parts, etc from a field.
This article presents 6 ways to return the year portion from a date in MongoDB.
Continue readingList of MongoDB Date Operators, Methods, & Variables
This article contains a list of date operators, methods, and variables that you can use when working with dates in MongoDB.
Continue readingMongoDB Date() Method
In MongoDB, the Date()
method returns a date either as a string or as a Date object.
- When you call it as
Date()
, it returns the current date as a string in themongo
shell. - When you call it as
new Date()
, it returns the current date as a Date object.
You can also provide a specific date as an argument to new Date()
, so that it uses that date.