March 26, 2011

Vb.Net Code to get Financial Year


 Function GETFINYR(ByVal strDate)  
 Dim strDt, strenddt, strstdt  
 Dim strdd, strmm, stryy, strst_dt, strend_dt  
 Dim date1, enddate, startdate  
 strDt = Split(strDate, "/")  
 strdd = strDt(0)  
 strmm = strDt(1)  
 stryy = strDt(2)  
 If Right(stryy, 2) = "99" Then  
 strend_dt = "31/03/" & Left(stryy, 2) + 1 & "00"  
 Else  
 If Right(stryy, 1) <> "9" Then  
 strend_dt = "31/03/" & Left(stryy, 3) & Right(stryy, 1) + 1  
 Else  
 strend_dt = "31/03/" & Left(stryy, 2) & Right(stryy, 2) + 1  
 End If  
 End If  
 strenddt = Split(strend_dt, "/")  
 strst_dt = "01/04/" & stryy  
 strstdt = Split(strst_dt, "/")  
 date1 = CDate(CInt(stryy) & "/" & CInt(strmm) & "/" & CInt(strdd))  
 enddate = CDate(CInt(strenddt(2)) & "/" & CInt(strenddt(1)) & "/" & CInt(strenddt(0)))  
 startdate = CDate(CInt(strstdt(2)) & "/" & CInt(strstdt(1)) & "/" & CInt(strstdt(0)))  
 If date1 <= enddate And date1 >= startdate Then  
 If Right(stryy, 2) = "99" Then  
 stryy = Right(stryy, 2) & "00"  
 Else  
 If Right(stryy, 1) <> "9" Then  
 stryy = Right(stryy, 2) & Mid(stryy, 3, 1) & Right(stryy, 1) + 1  
 Else  
 stryy = Right(stryy, 2) & Right(stryy, 2) + 1  
 End If  
 End If  
 Else  
 If Right(stryy, 2) <> "00" Then  
 If CInt(Right(stryy, 2) - 1) <= 9 Then  
 stryy = "0" & (Right(stryy, 2) - 1) & Right(stryy, 2)  
 Else  
 stryy = (Right(stryy, 2) - 1) & Right(stryy, 2)  
 End If  
 Else  
 stryy = "99" & Right(stryy, 2)  
 End If  
 End If  
 GETFINYR = stryy  
 End Function