If you have a MongoDB collection with dates stored as strings, you can convert those into the Date BSON type if required.
Below are three ways to convert a string into a Date in MongoDB.
Continue readingIf you have a MongoDB collection with dates stored as strings, you can convert those into the Date BSON type if required.
Below are three ways to convert a string into a Date in MongoDB.
Continue readingMongoDB has a Date BSON type that allows you to store dates as dates.
You can also store dates as strings, if that’s what you need.
Taking it a step further, you can also convert a Date to a string.
This article presents three ways to convert a Date to a string in MongoDB.
Continue readingIn MariaDB, CONVERT()
is a built in function that converts a value to another data type. It takes a value of one type and returns a value of the specified type.
You provide the value as an argument when you call the function, as well as the type that you’d like it converted to.
CONVERT()
is similar to CAST()
.
In MariaDB, CAST()
is a built in function that converts a value to another data type. It takes a value of one type and returns a value of the specified type.
You provide the value as an argument when you call the function, as well as the type that you’d like it converted to.
CAST()
works similar to CONVERT()
.
The AT TIME ZONE
clause was introduced in SQL Server 2016 to convert a date into a datetimeoffset value in a target time zone.
This function is similar to some other T-SQL functions, such as SWITCHOFFSET()
and TODATETIMEOFFSET()
, however, the AT TIME ZONE
clause allows/(requires) you to specify the time zone offset by name, instead of an actual offset value.
This article explores how AT TIME ZONE
works, and explains its benefits when compared to the other functions mentioned.
In MongoDB, the $toUpper
aggregation pipeline operator converts a string to uppercase and returns the result.
In MongoDB, the $toLower
aggregation pipeline operator converts a string to lowercase and returns the result.
From MongoDB 4.0, you can use the $toObjectId
aggregation pipeline operator to convert a string to an ObjectId.
The string must be a hexadecimal string of length 24.
Continue readingFrom MongoDB 4.0, you can use the $toLong
aggregation pipeline operator to convert a value to a long.
From MongoDB 4.0, you can use the $toInt
aggregation pipeline operator to convert a value to an integer.