Forum Discussion
Roost1969
2 years agoFrequent 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?
amustafa
2 years agoSolution 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)