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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Riskworks114
Regular Visitor

SQL Date format not recognized in Paginated report

This is interesting.
In a paginated report the format string convert(VARCHAR (10),ThruDt  , 112)  is not working when the query includes a physical table.  When I eliminated the physical table the format string worked.  The query context is not complex, and should not be confusing the optimizer.  I have not tried to replicate this with an AdventureWorks database, as we don't have on in our Dev environment.  SQL Server 2022.
There is a workaround, but any suggestions?  This doe not seem to be a known issues as of now.  Thanks.
 
DECLARE @getdate DATE 
SET @getdate = GETDATE()
IF Object_Id('tempdb.dbo.#gp') IS NOT NULL DROP TABLE #gp
 
select YEAR1, PERIODID , @ThruDt AS 'ThruDt' , @getdate  AS 'GetDate'
into #gp
from (
select b.YEAR1,
b.PERIODID 
from MyTable
WHERE B.YEAR1 = @Year
AND B.PERIODID = @Period
) v
select  ThruDt  ,
convert(VARCHAR (10),ThruDt)            AS  'StrThruDt',
convert(VARCHAR (10),ThruDt  , 112)     AS  'StrThruDt_112',
convert(VARCHAR (10),GETDATE()  , 112)  AS  'StrGetDate__112',
convert(VARCHAR (10), ThruDt, 126) AS  'StrThruDt_126',
CONVERT(VARCHAR(4), YEAR(ThruDt)) +
RIGHT('0' + CONVERT(VARCHAR(2), MONTH(ThruDt)), 2) +
RIGHT('0' + CONVERT(VARCHAR(2), DAY(ThruDt)), 2) AS Period_Concatinated
from #gp
2 REPLIES 2
parry2k
Super User
Super User

@Riskworks114 really not sure what you are trying to achieve here, could you please provide a bit more context? 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Yes, absolutely.   A report that I am moving from RRSR to PBI has a query that includes a date conversion for Date data type to YYYYMMDD format with:  convert(VARCHAR (10),ThruDt , 112).  The data for this column is from the parameter @ThruDt which is part of a larger query that populates a tep table.  This works in SSRS and in SSMS.  In PBI the format qualifier is ignored, and the date displays as a normal date type.  I've tried severall things, including adding a date column populated with GETDATE() which the format worked.  

I added a data set with only the parameter and getdate columns and that works.  It's kind of strange that the format is not working in the query that is pulling data from a database along with a parameter column where the sql format is ignored.  I HTH.  Thx.

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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