954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

How to check 2 variable values in if condition using vbscript ?

0
By snehalj on Nov 2nd, 2010 1:10 pm

above code not working, y is 2010 and year0 is also 2010, as per my knowledge Equal should be displayed as output, but the condition does not get equal.
Pls help me for this.

year1 =rs.fields("FinYear") 
year0 = Mid(year1,1,4)'first year
year1= Mid(year1,5,4)'second year 
y = Year(Now())
if y = year0 then 
Response.Write "Equal"
Response.End 						
end if

Hi,
what is rs.fields("FinYear")? Is it a date? Is it the year?

I don't understand why you are using mid. If you want to extract the year from a date, simply use datepart, as following:

Response.Write DatePart("YYYY", Date())


This would result in 2010.

If this is not what you want, please let me know the value of rs.fields("FinYear").

Baradaran
Junior Poster in Training
88 posts since Feb 2007
Reputation Points: 11
Solved Threads: 7
 

hi
sorry i forget to write that,
"20102011" is get stored in FinYear or any other year in this format

year1 =rs.fields("FinYear") 
year0 = Mid(year1,1,4)'first year
year1= Mid(year1,5,4)'second year 
mon =rs.fields("iMonth")
y = Year(Now())
m = Month(Now())
if  cStr(y)= year0 then


the problem is solved using cStr function.
n by using Mid function "20102011" gets seperated as 2010 and 2011

Thank u

snehalj
Light Poster
29 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You