How to Convert Integer Fields to Date Type in Bold BI
When working with data sources in Bold BI, there may be instances where you need to convert a date field represented as integer to a date type. This is particularly common when dealing with SQL databases where the date field is a BIGINT type.
Bold BI provides the functionality to convert the INT type field to Date type using expressions. This can be achieved by creating a new expression field in the Expression dialog.
Steps to Convert INT to Date
- Open the Expression dialog in Bold BI.
- Create a new expression field.
The syntax for creating the expression will depend on the type of data source you are using. Here are some frequently used SQL database expressions:
- SQL Server:
CONVERT(DATE,CAST([registered] AS VARCHAR),111)
- MySQL:
convert(CAST([registered] AS CHAR),date)
- PostgreSQL:
TO_DATE(CAST([registered] AS VARCHAR),'YYYYMMDD')
- Oracle:
TO_DATE(CAST([registered] AS VARCHAR(250)),'YYYYMMDD')
In these expressions, “registered” is an example integer field name. Replace this with your corresponding integer field name.
After the expression is created, you can see the converted date values in the Data preview.
Please note that only BIGINT data can be converted to Date type. Not all INT types can be converted to Date.