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
Anonymous
Not applicable

Dateformat

Hello everyone, 

 

Can anyone help me to convert this text column into a date column? 

The text value looks like this 15-FEB-20 11.00.00.000000 PM.

 

1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

Hi @Anonymous 

if you need exactly DAX, not M formula use:

a. for only date

ColumnDate = DATEVALUE(FORMAT(LEFT([Columntext],9),"General Date"))

b. for the datetime column

ColumnDateTime = 
var _date = DATEVALUE(FORMAT(LEFT([Columntext],9),"General Date"))
var _time = TIMEVALUE(SUBSTITUTE(RIGHT([Columntext],LEN([Columntext])-10),".000000", ""))

RETURN
_date + _time

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

6 REPLIES 6
az38
Community Champion
Community Champion

Hi @Anonymous 

if you need exactly DAX, not M formula use:

a. for only date

ColumnDate = DATEVALUE(FORMAT(LEFT([Columntext],9),"General Date"))

b. for the datetime column

ColumnDateTime = 
var _date = DATEVALUE(FORMAT(LEFT([Columntext],9),"General Date"))
var _time = TIMEVALUE(SUBSTITUTE(RIGHT([Columntext],LEN([Columntext])-10),".000000", ""))

RETURN
_date + _time

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

When i try to run the formula i get this error: 
"Cannot convert value '' of type Text to type Date."

Do you have any solution for this? 

az38
Community Champion
Community Champion

@Anonymous 

do you have empty cells with data? if so, how do you want to calculate it? what date it should return?


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

I have a column with date values like this one: "15-FEB-20 11.00.00.000000 PM." but they are formated as text and not date/time. I want to format the column from text to date/time.

az38
Community Champion
Community Champion

@Anonymous 

yes, but error "Cannot convert value '' of type Text to type Date." says to me that it is possible that you have an empty cells in your Date column. How do you plan to perform empty cells?


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

Aaaaah! Yes now it works! I didnt see the blank cell.. Thank you!

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.

Top Solution Authors