-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: prasanth
Message 1 in Discussion


  Hi,      I am using this function below for finding the number of business 
days and am binding this data to Datalist control based on the id passed from  
other page ,Here is the sample code in aspx page   
      
<tr>
        <td><b>Outstanding Days:</b></td> 
        <td><font color="#0033ff">
          <%# 
GetBusinessDay(Container.DataItem("DateReceivedBOFA"),Datetime.Now.ToString,5,0)
 %>
         </font>
        </td> 
</tr>
 
Public Shared Function GetBusinessDay(ByVal startDate As DateTime, ByVal 
EndDate As DateTime, ByVal NoOfDayWeek As Integer, ByVal DayType As Integer) As 
Double 
Dim iWeek As Double 
Dim iDays As Double 
Dim isDays As Double 
Dim ieDays As Double 
Dim T As TimeSpan 
Dim strFDate, strEDate As SqlTypes.SqlDateTime 
If startDate.ToShortDateString = "" Then 
startDate = Convert.DBNull(SqlDateTime.Null) 
ElseIf EndDate.ToShortDateString = "" Then 
EndDate = Convert.DBNull(SqlDateTime.Null) 
End If 
iWeek = DateDiff("ww", startDate, EndDate) - 1 
iDays = iWeek * NoOfDayWeek 
If NoOfDayWeek = 5 Then 
If startDate.DayOfWeek = DayOfWeek.Saturday Then 
isDays = 7 - CType(startDate.DayOfWeek, Integer) 
Else 
isDays = 7 - CType(startDate.DayOfWeek, Integer) - 1 
End If 
Else 
isDays = 7 - CType(startDate.DayOfWeek, Integer) 
End If 
If NoOfDayWeek = 5 Then 
If EndDate.DayOfWeek = DayOfWeek.Saturday Then 
ieDays = CType(EndDate.DayOfWeek, Integer) - 2 
Else 
ieDays = CType(EndDate.DayOfWeek, Integer) - 1 
End If 
Else 
ieDays = CType(EndDate.DayOfWeek, Integer) - 1 
End If 
iDays = iDays + isDays + ieDays 
If DayType = 0 Then 
Return iDays 
Else 
Return T.Days - iDays 
End If 
End Function 
Now the problem is when i try to call the above function it works well,if the 
DateRecievedBOFA column is having some Date.Moreover this column is defined as 
Char(11) in SQLServer table.So when the column is empty or null,it displays the 
error message "Cast from Type DBNull to Type String is Not Valid  " or "Cast 
from string "" to type 'Date' is not valid   ". 
Please tell me how could i solve this issue. 
Thanks in advance, 
Vishnu 
  
  
 

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to