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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
Community Champion
Community Champion

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors