Conversion

Apply your knowledge about temporal data types by converting them into each other.

SQL provides the CAST operator, which allows casting a value of any type to a value of a specified target data type. As such, the CAST operator is particularly useful for the interwoven data types of date and time. As these types share common characteristics, e.g., DATETIME contains a DATE associated with a TIME, converting these data types into each other can be useful. However, conversion is not always possible and can be associated with an alteration of value or loss of information. For us to be aware of these nuances, let us consider the following table for the remainder of this lesson:

Get hands-on with 1400+ tech skills courses.