Formatting dates and numbers with functions
Besides using the FORMAT()
function to reformat dates and numbers, we can also use CONVERT()
to achieve the same goals. In the meantime, numbers can be manipulated by using functions such as ROUND()
, CEILING()
, and FLOOR()
. We’ll take a closer look at these functions in the following sections.
Formatting dates and numbers with CONVERT() and CAST()
The CONVERT()
function takes in three arguments. The first argument is the data field data type, which is used to define the target data type the query returns. The second is the data field we want to change the format of. The third argument is a style code. It is an integer expression that specifies how the CONVERT()
function will translate the expression. For a NULL
style value, NULL
is returned. The data type determines the range. CAST()
will also be used briefly in the examples because sometimes our data does not include time elements and we want to attach hour and minute information...