AWS Security ChangesHomeSearch

AWS documentdb documentation change

Service: documentdb · 2026-03-31 · Documentation low

File: documentdb/latest/developerguide/dayOfWeek.md

Summary

Added new documentation page for the $dayOfWeek operator in Amazon DocumentDB, including syntax, parameters, MongoDB shell examples, and code examples in Node.js and Python with connection strings

Security assessment

This change adds documentation for a new DocumentDB operator but does not address any specific security vulnerability. The code examples include security-relevant connection parameters (tls=true, tlsCAFile=global-bundle.pem) which demonstrate secure connection practices, but this is standard documentation for a feature, not a response to a security issue.

Diff

diff --git a/documentdb/latest/developerguide/dayOfWeek.md b/documentdb/latest/developerguide/dayOfWeek.md
index 8b1378917..46271dcf1 100644
--- a//documentdb/latest/developerguide/dayOfWeek.md
+++ b//documentdb/latest/developerguide/dayOfWeek.md
@@ -0,0 +1 @@
+[](/pdfs/documentdb/latest/developerguide/developerguide.pdf#dayOfWeek "Open PDF")
@@ -1,0 +3,135 @@
+[Documentation](/index.html)[Amazon DocumentDB](/documentdb/index.html)[Developer Guide](what-is.html)
+
+Example (MongoDB Shell)Code examples
+
+# $dayOfWeek
+
+The `$dayOfWeek` operator in Amazon DocumentDB extracts the day of the week from a given date field. It returns the day of the week as a number between 1 (Sunday) and 7 (Saturday), which is the same behavior as in MongoDB.
+
+**Parameters**
+
+  * `date field`: The date field to extract the day of the week from.
+
+
+
+
+## Example (MongoDB Shell)
+
+This example demonstrates how to use the `$dayOfWeek` operator to extract the day of the week from the `date` field in the `weather` collection.
+
+**Create sample documents**
+    
+    
+    db.weather.insertMany([
+      {
+        "temperature": 97.5,
+        "humidity": 0.60,
+        "date": new Date("2023-04-01")
+      },
+      {
+        "temperature": 95.2,
+        "humidity": 0.55,
+        "date": new Date("2023-04-02")
+      },
+      {
+        "temperature": 92.8,
+        "humidity": 0.65,
+        "date": new Date("2023-04-03")
+      }
+    ]);
+
+**Query example**
+    
+    
+    db.weather.aggregate([
+      {
+        $project: {
+          dayOfWeek: { $dayOfWeek: "$date" }
+        }
+      }
+    ]).pretty();
+
+**Output**
+    
+    
+    { "_id" : ObjectId("64272c6663f4f8ce422c2d91"), "dayOfWeek" : 7 }
+    { "_id" : ObjectId("64272c6663f4f8ce422c2d92"), "dayOfWeek" : 1 }
+    { "_id" : ObjectId("64272c6663f4f8ce422c2d93"), "dayOfWeek" : 2 }
+
+## Code examples
+
+To view a code example for using the `$dayOfWeek` command, choose the tab for the language that you want to use:
+
+Node.js
+    
+    
+    
+    const { MongoClient } = require('mongodb');
+    
+    async function main() {
+      const client = await MongoClient.connect('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false');
+      const db = client.db('test');
+      const collection = db.collection('weather');
+    
+      const result = await collection.aggregate([
+        {
+          $project: {
+            dayOfWeek: { $dayOfWeek: '$date' }
+          }
+        }
+      ]).toArray();
+    
+      console.log(result);
+    
+      await client.close();
+    }
+    
+    main();
+
+Python
+    
+    
+    
+    from pymongo import MongoClient
+    
+    def main():
+        client = MongoClient('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false')
+        db = client.test
+        collection = db.weather
+    
+        result = list(collection.aggregate([
+            {
+                '$project': {
+                    'dayOfWeek': { '$dayOfWeek': '$date' }
+                }
+            }
+        ]))
+    
+        print(result)
+    
+        client.close()
+    
+    if __name__ == '__main__':
+        main()
+
+![Warning](https://d1ge0kk1l5kms0.cloudfront.net/images/G/01/webservices/console/warning.png) **Javascript is disabled or is unavailable in your browser.**
+
+To use the Amazon Web Services Documentation, Javascript must be enabled. Please refer to your browser's Help pages for instructions.
+
+[Document Conventions](/general/latest/gr/docconventions.html)
+
+$dayOfMonth
+
+$dayOfYear
+
+Did this page help you? - Yes
+
+Thanks for letting us know we're doing a good job!
+
+If you've got a moment, please tell us what we did right so we can do more of it.
+
+Did this page help you? - No
+
+Thanks for letting us know this page needs work. We're sorry we let you down.
+
+If you've got a moment, please tell us how we can make the documentation better.