-2

I want to check if a date is greater than a specified date using VBScript in Classic ASP.

The same thing i got working in the following :

Check if a date is greater than specified date

but the above is using javascript.

I did it using JavaScript as :

var Jun16 = new Date('JUN-2016')
var SelectedDate=new Date("<% =session("month")%>" + "-" + "<% =session("yrs")%>")

if(SelectedDate.getTime() > Jun16.getTime())
{
grossinc=parseInt("<% =rset1("othermontize_benefit") %>") + parseInt("<% =rset1("basic") %>") + parseInt("<% =rset1("house") %>") + parseInt("<% =rset1("utility") %>")
}
else
{
grossinc=parseInt("<% =rset1("gross") %>") + parseInt("<% =rset1("bonus") %>") + parseInt("<% =rset1("arrears") %>") + parseInt("<% =rset1("ot") %>")

}

How can I get the same in vb in classic asp.

EDIT :

the data which is to be compared is in MON AND YYYY format , there is no such any date , month is selected from months dropdown in MON Format and year is selected from years dropdown in yyyy format , now i want to check if the selected criteria is greater than JUN-2016 ?

Thanks.

Community
  • 1
  • 1
Alina Anjum
  • 1,178
  • 6
  • 30
  • 53

1 Answers1

3

Something like this should work for you:

jun16 = CDate("Jun-2016") ' jun16 = 01/06/2016 00:00:00
selectedDate = CDate(Session("month") & "-" & Session("year"))

If selectedDate > jun16 Then
    Response.Write("Geater")
Else
    Response.Write("Less than or equal to")
End If
Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
  • sorry , actually i dont know any thing about vb , i am working on a project of classic asp where vb is used ,how can i do it in classic asp using vb :( – Alina Anjum Jul 13 '16 at 10:03
  • 1
    SORRY :( I modified it – Alina Anjum Jul 13 '16 at 10:06
  • the data which is to be compared is in MON AND YYYY format , there is no such any date , month is selected from months dropdown in MON Format and year is selected from years dropdown in yyyy format , now i want to check if the selected criteria is greater than JUN-2016 ? – Alina Anjum Jul 13 '16 at 10:06
  • it could be any day , the condition is depends upon the month and year , if the employee is generating the payslip of june 2016 the criteria will be different and after June 2016 criteria will be changed – Alina Anjum Jul 13 '16 at 10:09
  • In your suggested solution , How can I pass session("month") and session("yrs") at the place of selectedDate = Now – Alina Anjum Jul 13 '16 at 10:32
  • Microsoft VBScript compilation error '800a0401' Expected end of statement /payslip.asp, line 282 Dim jun16 as Date ----------^ – Alina Anjum Jul 13 '16 at 10:37
  • Microsoft VBScript runtime error '800a000d' Type mismatch: 'CDate' /payslip.asp, line 283 – Alina Anjum Jul 13 '16 at 10:48
  • `MsgBox()` is client-side VBScript won't work in server-side VBScript in Classic ASP use `Response.Write()`. – user692942 Jul 13 '16 at 11:03
  • I want to upvote the second example, but downvote the first since it doesn't match the question in any way, shape, or form. Hence, no vote from me. :/ – Martha Jul 13 '16 at 14:16
  • @Martha - it did when the question was originally posted and tagged as VB.NET. I will remove that part now... – Matt Wilko Jul 13 '16 at 14:16
  • @MattWilko: ah, that explains it. – Martha Jul 13 '16 at 14:21