Category / Section
How to Create a New Date Column Using Day, Month and Year Columns in Bold BI
Published:
In Bold BI, you can create a new date column using existing day month and year columns. This can be achieved by using the to_timestamp
function and the CONCAT
function.
Here is the step-by-step guide:
- Open the data source where you want to create the new date column.
- Click on the ‘Add’ button to add a new expression.
- In the ‘Expression Name’ field, give it a name, like
DayMonthYear
. - In the ‘Expression’ field, enter the following formula:
to_timestamp(CONCAT(cast([Year] as varchar(4)),'-',[Month],'-',[Day], ' 00:00:00'),'YYYY-Mon-dd')
This formula concatenates the year and month columns, along with a fixed day and time, to create a timestamp. The
cast
function is used to convert the year column to a string, and the to_timestamp
function is used to convert the resulting string to a timestamp.
- Click ‘Save’ to save the new expression.
Now, you have successfully created a new date column using the month and year columns.
Bold BI supports various data sources for the to_timestamp function such as:
- MySQL
- PostgreSQL
- Oracle Database
- Microsoft Azure SQL Database
- Amazon RDS
- Google BigQuery
- Snowflake
- SQLite
- Microsoft Access.
Note: The availability of the to_timestamp function may depend on the specific syntax and functions supported by each database system.
For SQL server, please utilize the expression mentioned below as it does not support the to_timestamp
function.
CONVERT(DATE, CAST([Year] AS VARCHAR(4)) + '-' + [Month] + '-' + [Day])