Skip to main content
August 22, 2021
Question

How to add new column in data store with conditions.

  • August 22, 2021
  • 1 reply
  • 0 views

I want to do some typecasting in data store and save it in new column . For example I import  the  excel and it read the date as varchar,if I change its data type as date then the value shows as 00-00-0000 , I want to do typecast for entire column and save it in a new column so that i will use the latestcolumn for query entity. Please help me on this

    1 reply

    selvakumark
    Participating Frequently
    August 23, 2021

    Hi [mention:09c3c3f20dcf4a978e012f3a58e91fa1:e9ed411860ed4f2ba0265705b8793d05],

    The primary recommendation would be to format the excel date column to the format "yyyy-mm-dd".

    If that's not possible in your case, then you can use the below sample query to transform the data once it is imported(I assumed your DB as MySQL)

    SELECT
        DATE_FORMAT(
            STR_TO_DATE(`DateInText`, '%d-%m-%Y'),
            '%Y-%m-%d'
        ) FROM Table;