# Operators

Operator expressions are similar to functions that take arguments.

abs | `$abs` | Returns the absolute value of a number |

acos | `$acos` | Returns a numeric value between 0 and π radians for x between -1 and 1 |

acosh | `$acosh` | Returns the inverse hyperbolic cosine of a number |

acl | `$acl` | Not applicable |

add | `$add` | Adds two or more array properties or expressions. In addition to numbers, a single Date value may be included in the array. |

and | `$and` | Evaluates to true if all conditions in the passed in array evaluate to true |

asin | `$asin` | Returns the arcsine (in radians) of a number |

asinh | `$asinh` | Returns the hyperbolic arcsine of a number |

atan | `$atan` | Returns the arctangent (in radians) of a number |

atan2 | `$atan2` | Returns the angle in the plane (in radians) between the positive x-axis and the ray from (0,0) to the point (x,y) |

atanh | `$atanh` | Returns the hyperbolic arctangent of a number |

ceil | `$ceil` | Always rounds a number up to the next largest integer |

convert | `$convert` | Not applicable |

cos | `$cos` | Returns the cosine of the specified angle, which must be specified in radians |

dateFromParts | `$dateFromParts` | Returns a date from the specified parts (year, month, and day values) |

dateFromString | `$dateFromString` | Converts a date object to a string in a specified format, and expects an array of [date_expression] |

dateToParts | `$dateToParts` | Returns a document that contains the constituent parts of a given Date value as individual properties |

dateToString | `$dateToString` | Converts a date object to a string according to a user-specified format |

dayOfMonth | `$dayOfMonth` | Returns the day of the month for a date as a number between 1 and 31 |

dayOfWeek | `$dayOfWeek` | Returns the day of the week for a date as a number between 1 (Sunday) and 7 (Saturday) |

dayofYear | `$dayofYear` | Returns the day of the year for a date as a number between 1 and 366 |

degreestoRadians | `$degreestoRadians` | Converts an input value measured in degrees to radians |

divide | `$divide` | Divides one number by another and returns the result |

exp | `$exp` | Takes the e^n of a number |

floor | `$floor` | Returns the largest integer less than or equal to the specified number |

hour | `$hour` | Returns the hour portion of a date as a number between 0 and 23 |

isoDayOfWeek | `$isoDayOfWeek` | Returns the weekday number in ISO 8601 format, ranging from 1 (Monday) to 7 (Sunday) |

isoWeek | `$isoWeek` | Returns the week number in ISO 8601 format, ranging from 1 to 53 |

isoWeekYear | `$isoWeekYear` | Returns the year number in ISO 8601 format |

log | `$log` | Takes the log of the first number in the second number's base |

log10 | `$log10` | Calculates the log base 10 of a number and returns the result as a double |

let | `$let` | Binds variables for use in the specified expression, and returns the result of the expression
View let for more information on how the let variable is used in mongodb operations. |

ltrim | `$ltrim` | Removes whitespace characters, including null, or the specified characters from the beginning of a string |

mergeObjects | `$mergeObjects` | Combines multiple documents into a single document |

milliseconds | `$milliseconds` | Returns the millisecond portion of a date as an integer between 0 and 999 |

minute | `$minute` | Returns the minute portion of a date as a number between 0 and 59 |

moment | `$moment` | Used as a wrapper for the moment.js library to parse, validate, manipulate, and display dates and times in JavaScript
Example to determine the difference between two dates:`$moment: [date, { 'diff': [date2, 'days'] }]` |

month | `$month` | Returns the month of a date as a number between 1 and 12 |

multiply | `$multiply` | Multiplies the value of a field by a number |

omit | `$omit` | Not applicable |

or | `$or` | Performs a logical OR operation on an array of two or more and selects the documents that satisfy at least one of the arguments |

pathTo | $pathTo | Sets a path and creates deep objects
Example:
`$pathTo: [{ $literal: {} }, 'configuration.reporting.enabled', true]` |

pick | `$pick` | Not applicable |

radiansToDegrees | `$radiansToDegrees` | Converts an input value measured in radians to degrees |

regexFind | `$regexFind` | Provides regular expression (regex) pattern matching capability in aggregation expressions |

regexFindAll | `$regexFindAll` | Provides regex pattern matching capability in aggregation expressions. The operator returns an array of documents that contains information on each match. |

regexMatch | `$regexMatch` | Performs regex pattern matching and returns |

replaceAll | `$replaceAll` | Replaces all instances of a search string in an input string with a replacement string |

replaceOne | `$replaceOne` | Replaces the first instance of a search string in an input string with a replacement string |

rtrim | `$rtrim` | Removes whitespace characters, including null, or the specified characters from the end of a string |

second | `$second` | Returns the second portion of a date as a number between 0 and 59, but can be 60 to account for leap seconds |

sin | `$sin` | Returns the sine of a value that is measured in radians |

split | `$split` | Divides a string into an array of substrings based on a delimiter |

sqrt | `$sqrt` | Calculates the square root of a positive number and returns the result as a double |

stdDevPop | `$stdDevPop` | Calculates the population standard deviation of the input values |

stdDevSamp | `$stdDevSamp` | Calculates the sample standard deviation of the input values |

strcasecmp | `$strcasecmp` | Performs a case-insensitive comparison of two strings |

strLenBytes | `$strLenBytes` | Returns the number of UTF-8 encoded bytes in the specified string |

strLenCP | `$strLenCP` | Returns the number of UTF-8 code points in the specified string |

substr | `$substr` | Returns the number of UTF-8 encoded bytes in the specified string |

substrBytes | `$substrBytes` | Returns the substring of a string |

substrCP | `$substrCP` | Returns the substring of a string |

tan | `$tan` | Returns the tangent of a value that is measured in radians |

toDate | `$toDate` | Converts a value to date |

toLower | `$toLower` | Converts a string to lowercase, returning the result |

toUpper | `$toUpper` | Converts a string to uppercase, returning the result |

trim | `$trim` | Removes whitespace characters, including null, or the specified characters from the beginning and end of a string |

week | `$week` | Returns the week of the year for a date as a number between 0 and 53 |

year | `$year` | Returns the year portion of a date |

Last modified 1yr ago