.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Get last seven days records excluding Weekend days ?

Posted By:      Posted Date: August 30, 2010    Points: 0   Category :Sql Server
Hi , I'm trying to extract records from table inserted in last seven working days . I'm unable to exclude Sunday and Saturday from this : select * from tb_Name where dt >=DateAdd(dd, DateDiff(dd, 0, Getdate()), 0) and dt<DateAdd(dd, DateDiff(dd, 0, GetDate())-7, 0) Any pointers would greatly  be valued and appreciated . Thanks .Rajkumar Yelugu

View Complete Post

More Related Resource Links

select records within 30 days of previous records

I have a table with a list of patient id's and there begin date and end dates as follows: ID     begin_date  end_date 1234 10/09/2009 10/16/2009 1234 12/16/2009 12/22/2009 1234 12/28/2009 12/30/2009 1234 01/13/2010 01/19/2010 1234 04/29/2010 05/05/2010 what i need to do is select the records that have an end_date within 30 days of a begin_date. So in the above example, i would need to get the following records: ID     begin_date   end_date 1234 12/28/2009   12/30/2009 1234 01/13/2010   01/19/2010 Because 12/28/2009 is 30 days within 12/22/2009 (previous end_date) and 01/13/2010 is within 30 days of 12/30/2009 (previous end_date) and 12/22/2009 (2nd previous end_date). is there a good way to do this using T-SQL?

How i can view last 5 days records in current Month

Suppose i have a tableAppno Receive_Date Send_Date 1 9/3/2010 9/3/2010 2 9/3/2010 null 3 9/4/2010 9/4/2010 4 9/9/2010 9/9/2010 i m trying to run this select * from search where datediff(d,send_Date,getdate()<5

Getting records that 7 days pass today's date


I want to get all records that are 7 days pass today's date and not equal to today's date.  Don't know how to write it so I can get records 7 days old but with this procedure I'm still getting records that are due today.  Hope this makes sense.  Can someone assist me.

select * from libraryrequest
where  duedate > getdate() and duedate != getdate()

How to remove weekend days from current row date and Previous row date ?


column0    Column1                     ResultColumn

1              Mon, 07/12/2002           0 days

2              fri, 11/12/2002              4 days

3              mon, 14/12/2002           1 days

Thanks & Regards, PSWASULE

create stored procedure to remove records older than 90 days.


Hi All, i want to create two new stored procedures to remove records older than 90 days from tables DirStaging.Trr.FullEnrollmentImport and DirStaging.Trr.WeeklyMonthlyImport. The same stored procedure will remove all records from Dir.dbo.ErrorTable where there is not a record in Dir.Trr.FullEnrollment and Dir.Trr.WeeklyMonthly.    Both the procedures will accept an input variable called @CleanupDays. This will be passed from the calling system. there is a field called EtlId in DirStaging.Trr.FullEnrollmentImport which i would have to use to get recent load of information. i mean, if i am loading thousand records then they would have same EtlId. so i guess i have to have @EtlId and @CleanupDays as input variables.

I tried something like moving all the data from the DirStaging.Trr.FullEnrollmentImport to temp table, truncate DirStaging.Trr.FullEnrollmentImport and apply condition on temp table to get recent

How to remove records from a table after certain days


I have records that were inserted into a sql server 2005 table using a stored procedure. I now need to remove or delete these records. The only problem is that the table does not contain a relevant column to define in my where clause when using delete command.

Is there any way I can identify these records for deletion.


Editor's Note: The Future: A Few Days Away


The past year has been full of uncertainty and change. A year ago, everything seemed to be falling into place. Windows XP was nearing final release. An RC version of the Microsoft . NET Framework was whetting our appetites for the final February release.

MSDN Magazine November 2002

Only 12 days left in the Code Contest!


We are having a fun coding contest to find the best solution to a fairly trivial coding problem.  Come along and show off your skills . you might just win a totally awesome Gyroscope Powerball!

Participate in the Code Contest!

Force password expiration after x days


Using C# and sqlmembershipprovider forms authentication, is there a way to force user password to expire and need to be reset after x number of days?

So if a user launches the website login.aspx page, when they type their userid, it will check if the password is expired and direct them to a Resetpassword.aspx page?

Sharepoint access dissabled automatically in every two days

The problem seems to be that our administrators grant access to specific portals / folders and then without warning or any actions from our part the next week access is disabled

Display 'Top Queries Over Previous 30 Days' to users


In the Site Usage Reports, there is a section for 'Top Queries Over Previous 30 Days'. I would like to display this information to users. 

Is there a existing webpart for this? 
Is the data stored in a list that can be used for this purpose?


Steve Clark

How to add days in date using javascript


Hi following is the javascript code which i used for adding days to date

my date is 25/08/2010  and i want to add 8 days to this date  the answer should be 03/09/2010. how it is possible. i tried following code but showing error.



<script type="text/javascript" language="javascript">

function check()
var myDate = new Date();
var vFormat="MM/dd/yyyy";
var vDay                = addZero(myDate.getDate()); 
var vMonth            = addZero(myDate.getMonth()+1); 
var vYearLong         = addZero(myDate.getFullYear()); 
var vYearShort        = addZero(myDate.getFullYear().toString().substring(3,4)); 
var vYear             = (vFormat.indexOf("yyyy")>-1?vYearLong:vYearShort) 
var vHour             = addZero(myDate.getHours()); 
var vMinute           = addZero(myDate.getMinutes()); 
var vSecond           = addZero(myDate.getSeconds()); 
var myDateString       = vFormat.replace(/dd/g, vDay).replace(/MM/g, vMonth).replace(/y{1,4}/g, vYear) 
myDateString           = myDateString.replace(/hh/g, vHour).replace(/mm/g, vMinute).replace(/ss/g, vSecond) 

function addZero(vNumber){ 
    return ((vNumber < 10) ? "0" : "") + vNumber 


Absence and vacation days webparts calculation



does any1 know if there is a webpart that can calculate an employee's vacation days. and when the employee request some vacation days it show the days that are left.

or is there a tutorial to create such a webpart?


month days in gridview


 Hello all,

I have a challenge of which I can't figure out how to achieve it.

at this moment I have a gridview that can be dynamicly filled with cell's based upon the number of items selected (throug a drop down list) by a user.

the user then can enter some values in the cells to perform a bulk insert.

What I rather want is that the user selects a month, like august, and then  the gridview is filled with the amount of days from that month, so you get 31 cells in the gridview. second all the first cells should be filled with the daynumber for that day...

I hope the explanation is clear :)


Does anyone know a solution to this?





Need help in datetime conversion excluding invalid records

I have varachar(50) field which have date in yyyymmdd format Now i have to filter the data which are greater then server date I have following query Select * from MDB_CONTENT_INFO Where convert(datetime, CON_SCHEDULED_INDUCTION_DATE,112) >= GetDate() Problem ist aht i may have some invalid data other then valid one. I am getting error The conversion of a varchar data type to a datetime data type resulted in an out-of-range value. or Conversion failed when converting date and/or time from character string. I wanted to exclude those records but currently getting error for the query asKamran Shahid Senior Software Engineer/Analyst (MCP,MCAD,MCSD.NET,MCTS,MCPD.net[web])

The "60 days clean-up syndrome", how to recover?

Hi, Like many others, I woke up just to find that SP job has deleted my WF tasks (and history) from a critical system... The tasks are being displayed in all the reports and are important to understand the flow of a process. Now we must recover the data somehow, we are mostly interested in recovering the WF instance and tasks. We have DB backups. I know we should deal with the Workflow table, from which table does the tasks items come? Any tips? Free tools to recover list items from DB backup?   10x in advanced....

Percentage of matching days off among employee's

Hi All,i have Intime and Outtime of each employee for all the days of 1st,2,3,4 week.There will be a off for 1 day or 2 days for each employees.Based on this i need to calculate consisitency days off assignmanet i.e no of matching days off among employees in percentage.If there are 100 emplyees out of 100 employees 50 people may get week off on the same day(for example sunday). I want result in percentage.result like thisConsistency Days of assignment            Across 4 weeks            3 weeks                2weeks                0                                                             2%                                   0%     &
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend