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
bouyazbekj
Helper I
Helper I

How to change YYYYMMDDHHHH into date format

Hello everyone, 

 

How do I go about changing a YYYYMMDDHHHH into a yyyy-mm-dd format. 

 

Ticket date
201605010000
201702280000
201605080000
201702260000
1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

The MID function can help simplify things a bit

 

DATEVALUE(
LEFT(Table1[Ticket date], 4) &"-"&
MID(Table1[Ticket date], 5, 2) &"-"&
MID(Table1[Ticket date], 7, 2)
)

View solution in original post

4 REPLIES 4
AlexisOlson
Super User
Super User

The MID function can help simplify things a bit

 

DATEVALUE(
LEFT(Table1[Ticket date], 4) &"-"&
MID(Table1[Ticket date], 5, 2) &"-"&
MID(Table1[Ticket date], 7, 2)
)

I keep getting this error "Cannot convert value '--' of type Text to type Date." 

That sounds like you've got some blanks date strings it's trying to interpret.

AlB
Super User
Super User

Hi @bouyazbekj

One option below. I am not sure if there are built-in functions in DAX that do this. There might.

Calculated column (setting seconds to 0)

 

 

Table1[Date] =
VAR VYEAR =
    LEFT ( Table1[Ticket date]; 4 )
VAR VMonth =
    RIGHT ( LEFT ( Table1[Ticket date]; 6 ); 2 )
VAR VDay =
    RIGHT ( LEFT ( Table1[Ticket date]; 8 ); 2 )
VAR VHour =
    LEFT ( RIGHT ( Table1[Ticket date]; 4 ); 2 )
VAR VMins =
    RIGHT ( Table1[Ticket date]; 2 )
RETURN
    DATE ( VYear; VMonth; VDay ) + TIME ( VHour; VMins; 0 )

 

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.