Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
godtooro
Helper II
Helper II

Column DATE from column (20310312)

Dear all,

 

I've a column in this format: 20210312 (YYYYMMDD).

I want to create a new colum date.

How can I do it?

Because with date(column) it doesn´t works.

1 ACCEPTED SOLUTION
Samarth_18
Community Champion
Community Champion

Hi @godtooro ,

 

You could try below code:-

new_date = 
VAR _year =
    MID ( 'Table'[Column1], 1, 4 )
VAR _month =
    MID ( 'Table'[Column1], 5, 2 )
VAR _day =
    MID ( 'Table'[Column1], 7, 2 )
RETURN
 DATEVALUE ( _year & "-" & _month & "-" & _day )

Output:-

Samarth_18_0-1679580312842.png

 

Thanks,

Samarth

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

4 REPLIES 4
Samarth_18
Community Champion
Community Champion

Hi @godtooro ,

 

You could try below code:-

new_date = 
VAR _year =
    MID ( 'Table'[Column1], 1, 4 )
VAR _month =
    MID ( 'Table'[Column1], 5, 2 )
VAR _day =
    MID ( 'Table'[Column1], 7, 2 )
RETURN
 DATEVALUE ( _year & "-" & _month & "-" & _day )

Output:-

Samarth_18_0-1679580312842.png

 

Thanks,

Samarth

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Hi!!

 

Superb!! Works great! Thank you, thank you so much.

ichavarria
Solution Specialist
Solution Specialist

Hi @godtooro,

 

You can use the "FORMAT" function to convert the date in the YYYYMMDD format to a date format that can be used for analysis. Here's an example formula:

 

Date = DATEVALUE(FORMAT(Table1[Column], "####/##/##"))

 

In this formula, "Table1" refers to the name of your table and "Column" refers to the name of the column containing the YYYYMMDD date format. The "FORMAT" function converts the date to the format "####/##/##", which is the format recognized by the "DATEVALUE" function.

 

Best regards, 

Isaac Chavarria

If this post helps, then please consider Accepting it as the solution and giving Kudos to help the other members find it more quickly

Thank you so much!

godtooro_0-1679578653201.png

I've this error: number entry "20210329" is out of the interval YYYY/MM/DD.

Do you know why it is?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.