MongoDB $convert

In MongoDB, you can use the $convert aggregation pipeline operator to convert a value to a specified type.

You can convert any valid expression to a double, string, ObjectId, boolean, Date, integer, long, or decimal.

Read more

Converting Between Date & Time Data Types in SQL Server (T-SQL Examples)

When you convert between date and time data types in SQL Server, you need to be mindful of how the new data type will handle the value you’re trying to assign to it.

In some cases you might lose part of the value, in other cases you might gain a bunch of zeros (increasing storage size in the process). You may also end up with a value that’s been rounded up.

The following articles contain examples of conversions between the different date and time data types, with a particular focus on the issues I just mentioned.

Read more

Convert ‘datetimeoffset’ to ‘time’ in SQL Server (T-SQL Examples)

If you have a datetimeoffset value, but you don’t need the date and time zone offset part, converting it to time will save you a lot of storage space (while removing unnecessary details from the value). This article contains examples of converting a datetimeoffset value to a time value in SQL Server.

Read more

Convert ‘datetimeoffset’ to ‘date’ in SQL Server (T-SQL Examples)

If you have a datetimeoffset value, but you don’t need the time and time zone offset part, converting it to date will save you a lot of storage space (while removing unnecessary details from the value). This article contains examples of converting a datetimeoffset value to a date value in SQL Server.

Read more

Convert ‘datetimeoffset’ to ‘smalldatetime’ in SQL Server (T-SQL Examples)

This article contains examples of converting a datetimeoffset value to smalldatetime in SQL Server.

When you convert a datetimeoffset value to smalldatetime, the date and hours are copied. The minutes are rounded up (depending on the seconds value) and the seconds are set to 0.

Read more