Change a column's data type

For example, if you have a date column that is classified as a string in the schema.

Go to the data source list, select your data source, and switch to the schema tab. As you can see, our Date column is classified as a string. In order to use Chartio's built in date functions, we'll need to cast it to a date.

To accomplish this, we're going to create a custom column.  Click the Add Custom Column button in the table that contains the column you want to change.

For ease of use, we recommend naming your new column the same as the original column. Be sure to select the correct data type from the Type dropdown as well.

Consult the documentation for your database type to determine the correct syntax for casting as a date. Some common example are listed below.

MySQL

STR_TO_DATE(table_name.column_name, '%m-%d-%Y')

PostgreSQL, CSvs, Data Stores

CAST(table_name.column_name as date)

Google BigQuery

DATE(table_name.column_name)

Click Add Column when finished.

Because we always want to use our new custom column, we're going to hide the original column in the schema by unchecking the Visible checkbox.

Now we can use our new column as a date in Interactive Mode.

For more information about creating custom columns, see our documentation.