.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

Change existing holiday calculation function

Posted By:      Posted Date: October 14, 2010    Points: 0   Category :ASP.Net


What changes to the function below are needed to achieve those requirements:

- If you pass the same date, then 1 will be returned as the number of days

- Return '5' when passing 18.10.2010 to 22.10.2010 (Mo-Fr.)

- Return '0.5' when passing same date with (n) hours difference e.g. from 18.10.2010 08:00:00 and 18.10.10 12:00:00 (maybe I should ask start a new threand for this last one)

--author paul langan
--contact pflangan at gmail dot commmmmm
--date 2008-07-09
--function to get the number of business days between to dates
--if you pass the same date, then 0 will be returned as the number of days

--to illustrate the example, I've added a temporary table to hold the holidaydates,
--in practice this holiday date should already exist in the database and be pre populated with the bank holiday dates
CREATE FUNCTION "fnGetBusinessDays"
@startdate datetime,
@enddate datetime
RETURNS integer
DECLARE @days integer

SELECT @days =
- DATEDIFF(wk,@startdate,@enddate) * 2
WHEN DATENAME(dw, @startdate) <> 'Saturday' AND DATENAME(dw, @enddate) = 'Saturday' THEN 1
WHEN DATENAME(dw, @startdate) = 'Saturday' AND DATENAME(dw, @enddate) <> 'Saturday' THEN -1

View Complete Post

More Related Resource Links

Alternate languages - change on existing site

Hello. I need a help. In my template, when i choose in Site Actions -> Alternate languages and then on System account choose "Select Display Language". Work for RIBBON row and for all fields. But not work for a Quick Launch Menu. I have a .resx for Slovenian and English. I think i need some web update event receiver, but i do not find. If i use a template of SharePoint 2010 it's work also  Quick Launch Menu.

Change report in VS & deploy.....does NOT overwrite existing report in report manager


I have made some changes to most of my reports that have been previously deployed to report server.  I deploy the changed reports from VS and deployment is successful.  When I run report manager on the server to which they've been deployed, I get the old report.  I have to delete the existing in report manager and redeploy from VS in order to get the updated report in report manager.  This doesn't seem right. 

Am I doing something wrong???



By the way...this doesn't happen all the time.......

how to change the existing page Layout (Share Point 2007)


Hi All,


i have page with some content in a two webpart Zone. I want to change it another layout (3 Webpart zone).

Is there any direct way that i can change the Layout and the content remain intact. (Share Point 2007)

Thanks and Regards Er.Pradipta Nayak

Change Content Type then Change Page Layout of an Existing Page


One of our content managers has added about 10 new web pages but has used the wrong page layout.  The site that these pages are in has 3 options of page layout that can be used.  They are:

(WDC Article) One Column-Std
(WDC Article) Two Column-Std
(WDC News) Public Notices and News

As you can see, there are 2 content types within the site.  The content manager has used the "(WDC Article) One Column-Std" page layout instead of the "(WDC News) Public Notices and News" page layout.

I have tried to edit the page layout via the 'Page Settings and Schedule' area but I only get the "(WDC Article) One Column-Std" and "(WDC Article) Two Column-Std" page layout options - there is no option to select "(WDC News) Public Notices and News".

I have tried to change the page content type from WDC Article to WDC News so I will have the "(WDC News) Public Notices and News" page layout option but it keeps reverting back to WDC Article or I get an error.

Any ideas of how I can change all pages that use "(WDC Article) One Column-Std" page layout to "(WDC News) Public Notices and News" page layout (the correct layout)?

Thanks :)

how to change infopath form time (function now())

my infopath form has a default time now() for the field. my sp2010 server has correct time and time zone, for example 4:11pm EST now, but when open the form in sp2010 web browser form, it shows 1:11pm. any idea how to fix it?
however, if I do preview, it shows correct ime 4:11pm

help to change from cursor to cte or window function or set based

Hi i have table lots of heartbeats i need to know when heartbeat started and when it stopped, and not all the heartbeats in between. Can be multiple heartbeat stops. Thanks
set nocount on
create table #temp (id int, alive bit, checktime datetime)
insert #temp values (1,1,dateadd(minute,-7,GETDATE()))
insert #temp values (1,1,dateadd(minute,-6,


How to calculate childs age,but when i enter childs age as '03/27/2007' it returns 3 years where as actual age is 2 yr 11 months

How to Localize Windows Forms and Change the Language at Runtime

Localization is the process of customizing your application to a particular language, culture or locale. Visual Studio provides support for localizing Windows Forms with much ease. In this article, we will see how to localize windows forms and give the user the ability to change to his preferred language at runtime.
When you run a localized application, the appearance is determined by two culture values. The UICulture property is used to specify which resource files will be loaded for the form. The Culture property, on the other hand, determines how strings such as dates, numerals, and currency amounts are formatted.
Let us see the steps required to create a localized form. You can then expand this example and adopt the same approach for the rest of the forms in your project

calculation, field and map traverse adjustment, and coordinate transformation

Free Pocket PC land surveying software -- COGO calculation, field and map traverse adjustment, and coordinate transformation -- for students and professionals.

Content page control passes as argument to javascript function


Here is the content page:


<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="JavaDynamicCopyValue.aspx.cs" Inherits="JavaDynamicCopyValue" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 <script type="text/javascript" >
 function copyValue(input, output )
   ouput.value = input.value;
   return true;
 <asp:TextBox ID="txt1" runat="server" onchange="copyValue(this,document.getElementById('<%=txt2.ClientID%>'))"></asp:TextBox>
    <br />
    <br />
    <asp:TextBox ID="txt2" runat="server"></asp:TextBox>


I got a javascript run time error says output is undefined. if I view source of the page, the txt1 markup became:

<input name="ctl00$ContentPlaceHol

Selected to change the background color of the page



As this site, http://www.borfin.com.tr/genel/Default.aspx, How can I change the background color selected pages.

Bug: Does not change column type from nvarchar to ntext


Scenario: If you create a table with a column of type nvarchar, populate it with some content and try to modify it using the WebMatrix editor, from nvarchar to ntext, it does not display any error message or warning that this is not possible. It silently saves and reverts the change, back to nvarchar. Wasted some hours on this issue as I thought my column was ntext, but in fact was still nvarchar.

Expected behavior: It should change to ntext, or if SQL CE doesn't support that, it should notify the user that no change was applied.

How to change the default page base class?


I've tried setting the <pages pageBaseType="DynamicWebPage" /> value in web.config, but when I response.write out the page type, I'm still getting Microsoft.WebPages.WebPage.

I'm simply trying to sub-class WebPage and add some additional functionality such as a dynamic PageData dictionary similar to Phil Haack's dynamic ViewData dictionary.



connection to SQL Server files (*.mdf) require SQL server express 2005 to function properly.


I dont have the SQL EXPRESS installed instead I have SQL Standard Edition.

 I have two SQL Server instances installed.

 1- UserLT (this is sql 2000)
2- UserLT\SQL2005 (this is SQL 2005 named instance)

But when i try to add a database to my VS website project I get the following error:

Connection to SQL Server files (*.mdf) require SQL server express 2005 to function properly. please verify the installation of the component or download from the URL: go.microsoft.com/fwlink/?linkId=4925

I went in Tools>Opetions>DataBase tools>Data Connection>Sql Server Instance Name (blank for default)

and changed the "SQLEXPRESS" to "USERLT\SQL2005".

But I still get the same error message. Any ideas how i can resolve this issue?

SqlDataSource how to change the stored procedures at run time



Is it possible to change the select, insert and update stored procedure of an SqlDataSource at run time. I don't mean to change the definition of the stored procedure, but I mean to change the assignment, i.e. To change the select stored procedure from "selectSP1" to "selectSP2" at run time. Is it possible?



Public Shared function doubt????

I am using VB.net/ASP.NET and SQL Server 2000 for a web application.

For populating the dropdowns, I wrote a Public Shared function LoadDDL(), in which I pass the dataset and dropdown name to set.

I have my doubts that this function will produce unexpected results for concurrent users. And will mix the results among sessions because it is a Shared function.

I am confused here. Is it the right way to go?

Please advice. Thanks in advance.


URL Routing and Existing HttpHandler problems


Hello everyone,

I have a problem:

I am currently using 2 features: 

1. HttpHandler

Registering the path="res.aspx" verb="*"

2. URL Routing:

Registering with this pattern: "Company/Edit/{*companyId}","~/CompanyEdit.aspx"

In my CompanyEdit.aspx page, I used httphandler res.aspx to generate some images at client.

  • res.aspx?img=1
  • res.aspx?img=3

Now the problem is here, the page is load success with companyId = "12345", but when the images was loaded at client, it loaded the CompanyEdit.aspx again and show error with wrong id.  

I have debug and find the problem that because when image's urls were generated to client with url=res.aspx?img=1, url=res.aspx?img=3, the asp.net will understand that they are Company/Edit/res.aspx?img=1, Company/Edit/res.aspx?img=3 when it maps with URL Routing pattern.

=> So the CompanyEdit.aspx was load again with wrong id (id now is "res.aspx"). 

So, do you have any ideas to solve this problem, or other design.

Thanks, and best regard

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