cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Pawan
Frequent Visitor

Date Time Format Help

Hi Team,

 

Please can you help me to convert below date field into Date Time format in DAX to use in Tabular model.

Input:

 

Pawan_0-1672837743564.png

Expected Output format:

Pawan_1-1672837830067.png

 

 

12 REPLIES 12
v-xinruzhu-msft
Community Support
Community Support

Hi @Pawan 

Maybe you can transfer data in power query, and change it as datetime type

e.g:

 

 

vxinruzhumsft_0-1672907452173.png

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-xinruzhu-msft I am working on Tabular cube and loading into Power BI. I can apply onl dax Convertion in Tabular cube.

Hi @Pawan 

You can try this code:

Column = CONVERT(LEFT([Column1],19),DATETIME)
vxinruzhumsft_0-1672908547310.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi @v-xinruzhu-msft I am getting this error Can't convert value of type text to Datetime

tamerj1
Super User
Super User

Hi @Pawan 

please try

CONVERT ( LEFT ( 'Table'[HistoryDateOld], 20 ), DATETIME )

It should be 19

@shalinderverma 

Could be. I thought the space counts. Probably not?

Pawan
Frequent Visitor

Hi @tamerj1  I am getting error like Can't convert value of type text to Datetime

@Pawan 

Seems it is not recognizing the YYYY-MM-DD format. In this case am afraid that it has to be done manually by extracting the year, the month, the day using LEFT and MID functions wrapped by VALUE then using the DATE function to calculate the date out of them. 
on the other hand you can use MID to extract the time wraped with CONVERT - TIME

Then add the time to date like _date + _time

shalinderverma
Resolver II
Resolver II

If you do not need all datetime precision anywhere in the model, I suggest to format it in the source.

I don't have database accesss. i am looking for solution in DAX.

What about PowerQuery?

Helpful resources

Announcements
Join Arun Ulag at MPPC23

Join Arun Ulag at MPPC23

Get a sneak peek into this year's Power Platform Conference Keynote.

PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Top Solution Authors
Top Kudoed Authors