difference between two dates as number of weeks and days
Hi Can any body help with an expression which will give the result of the DateDiff(Fields!CREATEDDATE.Value,Fields!DELIVERYDATE.Value) as the number of weeks and days ? Thanks  Kiwi_Wizz
May 19th, 2011 6:12pm

Hallo Kiwi_Wizz, I would suggest to put the definition into the SQL-Statement. Please find an example with any startdate and actual date: DECLARE @StartDate datetime DECLARE @ActualDate datetime SET @StartDate = '20110405' SET @ActualDate = GETDATE() SELECT DATEDIFF(ww, @startDate, @ActualDate) AS CalendarWeek, DATEDIFF(dd, DATEADD(WW, 6, @StartDate), @ActualDate) AS CalenderDays <p> Instead of my variables you have to use your start- and enddate.</p> Uwe Ricken MCIT Database Administrator 2005 MCIT Database Administrator 2008 MCTS SQL Server 2005 MCTS SQL Server 2008, Implementation and Maintenance db Berater GmbH http://www-db-berater.de
Free Windows Admin Tool Kit Click here and download it now
May 19th, 2011 6:33pm

Hi Uwe I must say I'm abit lost doing this, I have no problem inserting the SELECT statement. But what and where do I put the DECLARE @StartDate datetime DECLARE @ActualDate datetime SET @StartDate = '20110405' SET @ActualDate = GETDATE() ?? Bit of a beginner here. Thanks For your help MarkKiwi_Wizz
May 19th, 2011 11:25pm

Hi, In the report where you want to show the difference of dates you can use the expression in the textbox DATEDIFF("d",Fields!CREATEDDATE.Value,Fields!DELIVERYDATE.Value). This will give you the difference. Or else you can use a SQL query in the dataset and refert that calculated field in your SSRS. HTH, Ram
Free Windows Admin Tool Kit Click here and download it now
May 19th, 2011 11:31pm

DateDiff function has the first parameter that tells what kind of difference you want - in days, in weeks, etc. Alternatively, you can add a calculated field to the select statement that you use for as a Data Source for the report. Try select ..., DATEDIFF(day, CreatedDate, DeliveryDate) as [Days Difference], DATEDIFF(week, CreatedDate, DeliveryDate) as [Weeks Difference] FROM ... For every expert, there is an equal and opposite expert. - Becker's Law My blog
May 19th, 2011 11:45pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics