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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

SQL Server DQ Date data type

When connecting to SQL Server (2014 standard edition) and choosing direct query date data type is represented as DateTime in powerBI. e.g. 4/15/2004 12:00:00 AM. Since DQ doesn't allow transformation it can't get this date to show only date portion.

 

Suggestions?

1 ACCEPTED SOLUTION

Hi @Anonymous,

When I write T-SQL statements to get data from SQL Server, I can reproduce your issue.
1.PNG

In this case, you can directly change the data type of the date column in Report View, please click the Date column in the Fields panel of the following screenshot, then you can click on Modeling in the Desktop ribbon and change its type to Date.
2.PNG

Also you can change the date format to your desired format.
3.PNG


Thanks,
Lydia Zhang

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
v-yuezhe-msft
Employee
Employee

Hi @Anonymous,

Firstly, I am not able to reproduce your issue that date data type is represented as DateTime in Power BI when connecting SQL Server 2014 Standard edition via Direct Query option, please check the following screenshots. Power BI Desktop doesn’t change the Date data type to DateTime. Please make sure that your columns are defined as Date data type in SQL Server.

1.PNG2.PNG


Secondly, when we use Advanced filtering to filter a Date type field in Power BI Desktop, it still shows the time portion in visual level filter, from my point of view, this behavior is by design. I have reported this issue internally and will post back once I get any updates.

Thanks,
Lydia Zhang

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-yuezhe-msft,

 

Thanks for responding. This is definitely one of those "works on my machine" type thing. See the screenshot below. sqlserverversion.JPG

 

And the screen shot of PowerBI desktop here. Notice how it chagned it to DateTime:

 

datetime.JPG

Since this is a DirectQuery it won't let appy & save any transformation or datatype chagnes.

 

 

Hi @Anonymous,

When I write T-SQL statements to get data from SQL Server, I can reproduce your issue.
1.PNG

In this case, you can directly change the data type of the date column in Report View, please click the Date column in the Fields panel of the following screenshot, then you can click on Modeling in the Desktop ribbon and change its type to Date.
2.PNG

Also you can change the date format to your desired format.
3.PNG


Thanks,
Lydia Zhang

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yuezhe-msft It doesn't seem very intuitive to me that even when I do change the data type/format in Power BI that the output in the preview appears as 9/8/2016 but when the field appears in the visual it shows up as Thursday, September 8th, 2016... I don't ever see using that format in a visual...

The date datatype from SQL always by default is showing up as 9/8/2016  12:00:00000 (or something to that effect.


Looking for more Power BI tips, tricks & tools? Check out PowerBI.tips the site I co-own with Mike Carlo. Also, if you are near SE WI? Join our PUG Milwaukee Brew City PUG

@Anonymous Add an additional column in the dataset that returns the date in text format.

date.JPG


Looking for more Power BI tips, tricks & tools? Check out PowerBI.tips the site I co-own with Mike Carlo. Also, if you are near SE WI? Join our PUG Milwaukee Brew City PUG
Anonymous
Not applicable

@Seth_C_Bauer I've tried that and it works fine as a column but the issue is when you want to use that column a filter. Since it's text you can't perform any of the date filering. Workaround is to have one column for display (text) and another for filtering but this is a very dirty hack to accomplish a basic function and you still have the time portion that's always zero'd out in the filtering.

 

I've actually joined my entire Date dimension hoping to get around some of this stuff but I've not been successfull.

 

Just wondring if this is a known limitation.DateFilter.JPG

@Anonymous Must be.  I've found that you can change the data type on the direct query by clicking "Edit Queries" -> "Edit Queries" -> Highlight the column and change the data type, but even when selecting "Date" it looks right in the preview table pane, but when you go back to the visuals it shows up as (example: Sunday, January 1, 2012).

I was messing around with trying to force format in M, but it looks like this is a visual rendering issue with adjusting the format...

You could explore it further to see if I'm missing something in this section, but you do have access to modify the format in Direct Query using Edit Queries. And by opening "Advanced Editor" - you can modify the "M" code.


Looking for more Power BI tips, tricks & tools? Check out PowerBI.tips the site I co-own with Mike Carlo. Also, if you are near SE WI? Join our PUG Milwaukee Brew City PUG

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.