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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Roost1969
Frequent Visitor

Convert Timestamp into date-time

Goodday,

 

I have a CSV file withe a data-time field witch has the format (Jan 12, 2024 @ 19:39:03.793).

Is there a way to convert this format to a DD-MM-YYYY, HH:MM:SS  with a dax code?

6 REPLIES 6
amustafa
Solution Sage
Solution Sage

Try this. Adjust the table and column name accordingly. This formula assumes that your original column is in text format.

 

DateTime_Converted =
VAR textDateTime = datetimesample[datetime]
VAR cleanedDateTime = SUBSTITUTE(SUBSTITUTE(textDateTime, "@ ", ""), ",", "")
VAR datePart = LEFT(cleanedDateTime, LEN(cleanedDateTime) - 12)
VAR timePartWithMilliseconds = RIGHT(cleanedDateTime, 12)
VAR timePart = LEFT(timePartWithMilliseconds, 8)  // Extracting only the HH:MM:SS part
RETURN
    DATEVALUE(datePart) + TIMEVALUE(timePart)
 
 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Unfortunately this code doesn't work either, maybe I can send you a PBix?

Sure, that will help





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Roost1969
Frequent Visitor

thank you, de Time convert part works fine, but the Date part has a issue.  It says"Connot convert value 'Oct 31 2023' of type text to type Date.

amustafa
Solution Sage
Solution Sage

Well, you have two different formats of date in your data then. here's the updated DAX to handle both formats.

 

DateTime_Converted =
VAR textDateTime = datetimesample[datetime]
VAR containsTime = CONTAINSSTRING(textDateTime, "@")
VAR cleanedDateTime = SUBSTITUTE(SUBSTITUTE(textDateTime, "@ ", ""), ",", "")
VAR datePart = IF(containsTime, LEFT(cleanedDateTime, LEN(cleanedDateTime) - 12), cleanedDateTime)
VAR timePartWithMilliseconds = IF(containsTime, RIGHT(cleanedDateTime, 12), "00:00:00")
VAR timePart = IF(containsTime, LEFT(timePartWithMilliseconds, 8), timePartWithMilliseconds) // Extracting only the HH:MM:SS part or default to 00:00:00 if no time part
RETURN
DATEVALUE(datePart) + TIMEVALUE(timePart)

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Roost1969
Frequent Visitor

After a import of a new dataset, the dataconvert works.

Thanks you for your help.

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Users online (27)