I created a function to house this algorithm and the css3 full tutorial pdf performance of that function was very similar.
And when getting that date from a variable in code, I always convert the result to string as follows: "select FirstName from Students where DoB " String d MMM yyyy.
So you have a table which has a StartDate and EndDate column.
Even more, 16/11/12 supplied to MySQL database will be internally converted to, while Access database running on a UK regional setting computer will interpret and store it as 16th Nov 2012.The equation: (EndDate - StartDate) - ( (Number of Weeks between StartDate and EndDate x2) 1 if StartDate is a Sunday 1 if EndDate is a Saturday the SQL: declare @StartDate datetime, @EndDate datetimeselect @StartDate @EndDate'.I am writing this because I know sometimes some programmers may not be keen enough to detect the inherent conversion.So if we wanted to know how many days rather than 24 hour periods the date range includes within it we would need to 1 that number.Select (datediff(dd, @StartDate, @EndDate) 1) -Number of days between Start and End - ( (datediff(wk, @StartDate, @EndDate) * 2) -Weekend Days (case when datename(dw, @StartDate) 'Sunday' then 1 else 0 END) -Taking into consideration the startdate being a Sunday (case when datename(dw, @EndDate) 'Saturday' then.We need to take into account that if we define a start or end date as a weekend day then it should add these days onto the total to be deducted.Ive autodesk 3ds max 2011 32-bit tested it out in a few different scenarios and it seems to work.It might seem like you should calculate the time of the date to make sure, but you dont you can simple 1 the days.Ive just executed it against that data-set using the DateCreated as the StartDate and DateModified as the end date and its executed in a split second!(There are no indexes against the date columns in case you wondered).Im not going to include the SQL to generate test data to test this against, as I simply dont have time.So we can account for the days between the start and end date by calculating the number of weeks between the two dates and multiplying that number by 2, again using.I may put it into a function later if theres negligible performance difference in doing.