-5

I want to get difference between two dates using the datediff and i want to exclude the weekends.The Code below.

SqlDataAdapter sda = new SqlDataAdapter("SELECT [uSerial] " +", DATEDIFF(dd,[RestartDate],getDate()) as statusDuration ,[cutRefs] " "FROM [dbo].[tblFTTH_Fault_Tool]", conn);
DataTable ds = new DataTable();
sda.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();

kindly assist.

Mighty Badaboom
  • 6,067
  • 5
  • 34
  • 51
Mataga
  • 1
  • Have a look at [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). We are no clairvoyants here. Where are you struggle? Example data? What's not working? – Mighty Badaboom Jul 18 '17 at 10:26
  • Try running the same query directly on the db via SQL management studio and play around with it until you get expected output. We don't what is the expected output so very difficult to provide you a solution. – Chetan Jul 18 '17 at 10:29
  • I developed a web application that adds data to sql server,including the start date and committed date, so i am calculating the duration between the start date and committed date using the DateDiff, i want to get the number of days between the start date and the committed date but excluding the weekends. – Mataga Jul 18 '17 at 10:48

1 Answers1

0

i think you should use

SELECT DATEDIFF(day,'2014-06-05','2014-08-05') AS DiffDate

and result is

DiffDate 61

Manish Singh
  • 934
  • 1
  • 12
  • 27