Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get number of days between two dates mongodb query

db.collection.aggregate([
  {
    $project: {
      days: {
        $dateDiff: {
          startDate: "$start",
          endDate: "$end",
          unit: "day"
        }
      },
      _id: 0
    }
  }
])
Comment

get days months and years between dates mongodb

db.collection.aggregate([
  {
    $project: {
      Start: "$start",
      End: "$end",
      years: {
        $dateDiff: {
          startDate: "$start",
          endDate: "$end",
          unit: "year"
        }
      },
      months: {
        $dateDiff: {
          startDate: "$start",
          endDate: "$end",
          unit: "month"
        }
      },
      days: {
        $dateDiff: {
          startDate: "$start",
          endDate: "$end",
          unit: "day"
        }
      },
      _id: 0
    }
  }
])
Comment

PREVIOUS NEXT
Code Example
Javascript :: js obj getting count of properties 
Javascript :: disable button in swal popup 
Javascript :: js remove the last character from a string 
Javascript :: react yup password with number string and uppercase 
Javascript :: can you call api in next.js getserverside props 
Javascript :: set data-id javascript 
Javascript :: read file size javascript 
Javascript :: user api testing 
Javascript :: react native tab.screen hide title 
Javascript :: javascript js isNumber 
Javascript :: btoa is not defined js 
Javascript :: count number of word in javascript 
Javascript :: vue cli - Uncaught SyntaxError: Unexpected token < 
Javascript :: vue.js slots 
Javascript :: javascript force precision to 2 decimal numbers 
Javascript :: how to change user password firebase 
Javascript :: flatlist horizontal 
Javascript :: quine 
Javascript :: javascript format number 2 digits 
Javascript :: generate a random id 
Javascript :: How to hthe amount of users online in discordjs 
Javascript :: set js 
Javascript :: how to remove timezone from date in javascript 
Javascript :: javascript remove innerhtml 
Javascript :: javascript url check 
Javascript :: java gson string to json 
Javascript :: ERESOLVE unable to resolve dependency tree 
Javascript :: scroll to div js 
Javascript :: downgrade node version windows using npm 
Javascript :: javascript Inserting values in between an array 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =