Here are some options for subtracting one or more minutes from a datetime expression in MariaDB.
Continue readingFix “$pullAll requires an array argument but was given a double” in MongoDB
If you get the “$pullAll requires an array argument but was given a double” error in MongoDB, it’s because you didn’t provide an array as the value to replace.
Continue readingHow CONVERT_TZ() Works in MariaDB
In MariaDB, CONVERT_TZ()
is a built-in date and time function that converts a datetime value from one time zone to another.
When you call the function, you pass three arguments: the time, the time zone to convert from, and the time zone to convert to.
Continue readingFix: Access denied for user ‘root’@’localhost’ in MariaDB
If you’re getting an error telling you that access is denied for the root
user in MariaDB, this article may help.
How to Set Up Named Time Zones in MariaDB
If you want to use named time zones in MariaDB, you’ll need to make sure they’ve been configured.
By “named time zones”, I mean being able to use strings like America/Los_Angeles
instead of −08:00
or −07:00
when specifying the time zone. For example, when using the CONVERT_TZ()
function.
Here’s how to configure named time zones in MariaDB.
Continue readingHow to Format the Date in MongoDB
If you have documents that store dates as Date objects, but you want to return them in a different format, you can use the $dateToString
aggregate pipeline operator.
For example, you might want a date to be returned in mm/dd/yyyy
format instead of the long ISODate()
format that includes minutes, seconds, milliseconds, etc
The $dateToString
operator converts the Date object to a string, and optionally allows you to specify a format for the resulting output.
Fix “longitude/latitude is out of bounds” in MongoDB when Creating a 2dsphere Index
If you’re getting a “longitude/latitude is out of bounds” error when trying to create a 2dsphere index in MongoDB, it could be due to your longitude and latitude coordinates being in the wrong order.
Continue reading8 Ways to Add Days to a Date in MariaDB
MariaDB provides several ways to add a certain number of days to a given date. For example, you might want to add 10 days to a date, or 30 days, or even just 1 day. Fortunately, MariaDB makes this easy.
Here are 8 ways to add a number of days to a given date in MariaDB.
Continue readingHow to Check Whether an Index is Hidden in MongoDB
From MongoDB 4.4, it’s possible to hide an index from the query planner. This allows you to evaluate the potential impact of dropping an index without actually dropping the index.
You can use the getIndexes()
method to check whether or not an index is hidden. If an index is hidden, that index will display a hidden
field as having a value of true
(i.e. "hidden" : true
).
How to Reference JSON Keys that Contain Special Characters when using OPENJSON, JSON_QUERY, and JSON_VALUE (SQL Server)
If you’re using a T-SQL function such as OPENJSON()
, JSON_QUERY()
, or JSON_VALUE()
, you might be wary of any non-alphanumeric characters that might be in the JSON document that you’re working with. Especially if those special characters are in the key names, and you need to reference those key names.