Skip to content

Commit a1b5808

Browse files
jocelyn-mendez1Jocelyn Mendez
authored andcommitted
DOCS-14879 updated convert page (#165)
* DOCS-14879 updated convert page * DOCS-14879 adding timestamp to bool conversion Co-authored-by: Jocelyn Mendez <[email protected]>
1 parent f5b89b9 commit a1b5808

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

source/reference/operator/aggregation/convert.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ boolean:
192192

193193
- | Returns true.
194194

195+
* - Timestamp
196+
197+
- | Returns true.
198+
195199
The following table lists some conversion to boolean examples:
196200

197201
.. list-table::
@@ -913,6 +917,10 @@ date:
913917
- Returns a date that corresponds to the timestamp of the
914918
ObjectId.
915919

920+
* - Timestamp
921+
922+
- Returns a date that corresponds to the timestamp.
923+
916924
The following table lists some conversion to date examples:
917925

918926
.. list-table::
@@ -983,6 +991,12 @@ The following table lists some conversion to date examples:
983991
}
984992
- "Could not convert to type date."
985993

994+
* - .. code-block:: javascript
995+
:copyable: false
996+
997+
{ input: Timestamp({ t: 1637688118, i: 1 }), to: "date" }
998+
- ISODate("2021-11-23T17:21:58.00Z")
999+
9861000

9871001
.. seealso::
9881002

source/reference/operator/aggregation/toDate.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ date:
109109
- Returns a date that corresponds to the timestamp of the
110110
ObjectId.
111111

112+
* - Timestamp
113+
114+
- Returns a date that corresponds to the timestamp.
115+
112116
The following table lists some conversion to date examples:
113117

114118
.. list-table::
@@ -142,6 +146,9 @@ The following table lists some conversion to date examples:
142146
* - ``{$toDate: "Friday"}``
143147
- Error
144148

149+
* - ``{$toDate: Timestamp({ t: 1637688118, i: 1 })}``
150+
- ISODate("2021-11-23T17:21:58.00Z")
151+
145152
Example
146153
-------
147154

source/release-notes/5.2.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ MongoDB 5.2 introduces the following aggregation operators:
4545
* - :expression:`$sortArray`
4646
- Sorts an array based on its elements.
4747

48+
General Aggregation Improvements
49+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50+
51+
:expression:`convert` Supports Timestamp Conversion to Date
52+
```````````````````````````````````````````````````````````
53+
54+
Starting in MongoDB 5.2, you can convert timestamps to dates using the
55+
:expression:`$convert` operator. The :expression:`$toDate` operator can
56+
also convert timestamps.
57+
4858
.. _5.2-rel-notes-sharding:
4959

5060
Sharding

0 commit comments

Comments
 (0)