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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
JSJB
Helper I
Helper I

Telling if date format includes time

Hello,

 

I am developing a custom visual that shows given columns of data and allows some data entry as well.


I am basing this datagrid on Material UI's datagrid component. However, this component has distinction between date format and date-time format.

 

I have implemented the valueformatting utilities in my project and the given format for a date measure works very well. However, as all values are in datetime, I am having difficulty determining if a given measure's format is datetime or only date.

 

I could do some inferencing on the format string that is given, but I'm curious if there isn't some other way of determining this?

 

Thanks in advance 🙂

2 REPLIES 2
JSJB
Helper I
Helper I

Hello @lbendlin, thank you for your reply 🙂

 

I think your suggestion is good, but I am worried about performance of it. Because, to determine if something is a date format, we would theoretically need to evaluate every single value, would we not? If we check the first value and find it's a date, we can't exclude the possibility that the value after that may be datetime (and so on and so on). 

 

Either way, I've thought about it and believe that it's best to consider all date measures passed to be datetime. I will just include an option for users to specify if they want it to be date after the fact (while still using their formatting no matter what it is). I think this gives the end-user more flexibility.

 

Thanks for your help!

lbendlin
Super User
Super User

Convert the datetime value to a number and check if it has fractions or not.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Kudoed Authors