Forum Discussion
Why does Line Chart still show datetime when I already extracted time by changing Data type
- 2 years ago
gitgithan There is no date or time data type in DAX, only datetime. DAX Data types – DAX Guide
I ran an experiment. If you have a datetime field and switch it to time you see only the time. If you switch it back to datetime, still only the time. But if you switch it to date, then you see the original date, so the original date is still there from the looks of it.
Greg_Deckler
Let me confirm that. You are saying the Data type dropdown does not change the data type?
In both methods i used this dropdown.
Method 1 changed Date/Time to Time
Method 2 changed Text to Time (With additional popup warning)
Method 2's warning makes me think method 1 is also actually changing data type and not just format. Also there's another dropdown for Format so i don't think Data type dropdown is for formatting.
Is there this nuance where, if i use the Data type dropdown, and move across options of {Date/time, Date, Time}, or {Whole number, Decimal number, Fixed decimal number}, it's a format change.
But if i mentally group the numbers and dates as 1 type each, and move across {The 3 numbers, The 3 dates, Text, True/False, Binary}, only then there is a type change?
Your method worked great, thanks for introducing.
Would you know why when I tried repeating method 2 on another similar column, but with NULLS, i get "Cannot convert value '' of type Text to type Date."
It's confusing because i'm not even selecting Date from the Data type dropdown, but Time. Your method works for this column too, and nulls are left alone as nulls after conversion.
Explanation of Greg's expression
Datetime values are stored as floating-point numbers (https://dax.guide/dt/datetime/), where the integer part represents the number of days since a specific epoch (usually December 30, 1899), and the fractional part represents the fraction of a day (time).
The integer part of the datetime value represents the whole days.
Subtracting the integer part from the original datetime value isolates the fractional part, which corresponds to the time of day.
- Greg_Deckler2 years ago
Community Champion
gitgithan There is no date or time data type in DAX, only datetime. DAX Data types – DAX Guide
I ran an experiment. If you have a datetime field and switch it to time you see only the time. If you switch it back to datetime, still only the time. But if you switch it to date, then you see the original date, so the original date is still there from the looks of it.