isdate problem 
Author Message
 isdate problem

I'm having a strange problem with the isdate function:

mydate = "32/11/01"
Response.Write isdate(mydate) & "<br>"
Response.Write "DAY:" & day(mydate) & "<br>"
Response.Write "MONTH:" & month(mydate) & "<br>"
Response.Write "YEAR:" & year(mydate) & "<br>"

I create a date, 32/11/01 (in dd/mm/yy format).
This date is invalid, since November does not have 32 days, but isdate
evaluates this to true.
VBScript appears to intrpret the date as 01/11/32
i.e. 01 Dec 1932

Does anyone have any ideas on how to deal with this?
I want VBScript to recognise 32/11/01 as an invalid date.
I don't think it's due to server settings.

Thanks in advance,

Sean Tynan

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sun, 11 May 2003 03:00:00 GMT  
 isdate problem
Sean,

isdate just validates the date, you need to check using if-statements (or
something like that) to check if it's valid or not...

e.g

mydate = "32/11/01"

if isdate(mydate) then
   Response.Write "DAY:" & day(mydate) & "<br>"
   Response.Write "MONTH:" & month(mydate) & "<br>"
   Response.Write "YEAR:" & year(mydate) & "<br>"
else
   response.write("Invalid date")
end if

hope it helps
/Lasse

Quote:

> I'm having a strange problem with the isdate function:

> mydate = "32/11/01"
> Response.Write isdate(mydate) & "<br>"
> Response.Write "DAY:" & day(mydate) & "<br>"
> Response.Write "MONTH:" & month(mydate) & "<br>"
> Response.Write "YEAR:" & year(mydate) & "<br>"

> I create a date, 32/11/01 (in dd/mm/yy format).
> This date is invalid, since November does not have 32 days, but isdate
> evaluates this to true.
> VBScript appears to intrpret the date as 01/11/32
> i.e. 01 Dec 1932

> Does anyone have any ideas on how to deal with this?
> I want VBScript to recognise 32/11/01 as an invalid date.
> I don't think it's due to server settings.

> Thanks in advance,

> Sean Tynan

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sun, 11 May 2003 03:00:00 GMT  
 isdate problem
Convert the month to MonthName, and the year to 4 digits, and you can validate it with IsDate.

--

Bill James
Microsoft MVPDTS

?Win9x VBScript Utilities?
www.billsway.com/vbspage/

Quote:

> I'm having a strange problem with the isdate function:

> mydate = "32/11/01"
> Response.Write isdate(mydate) & "<br>"
> Response.Write "DAY:" & day(mydate) & "<br>"
> Response.Write "MONTH:" & month(mydate) & "<br>"
> Response.Write "YEAR:" & year(mydate) & "<br>"

> I create a date, 32/11/01 (in dd/mm/yy format).
> This date is invalid, since November does not have 32 days, but isdate
> evaluates this to true.
> VBScript appears to intrpret the date as 01/11/32
> i.e. 01 Dec 1932

> Does anyone have any ideas on how to deal with this?
> I want VBScript to recognise 32/11/01 as an invalid date.
> I don't think it's due to server settings.

> Thanks in advance,

> Sean Tynan

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sun, 11 May 2003 03:00:00 GMT  
 isdate problem
formatdatetime(cdate("32/11/01"),vblongdate)

==> Tuesday, November 01, 1932

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup...
--

Quote:

> I'm having a strange problem with the isdate function:

> mydate = "32/11/01"
> Response.Write isdate(mydate) & "<br>"
> Response.Write "DAY:" & day(mydate) & "<br>"
> Response.Write "MONTH:" & month(mydate) & "<br>"
> Response.Write "YEAR:" & year(mydate) & "<br>"

> I create a date, 32/11/01 (in dd/mm/yy format).
> This date is invalid, since November does not have 32 days, but isdate
> evaluates this to true.
> VBScript appears to intrpret the date as 01/11/32
> i.e. 01 Dec 1932

> Does anyone have any ideas on how to deal with this?
> I want VBScript to recognise 32/11/01 as an invalid date.
> I don't think it's due to server settings.

> Thanks in advance,

> Sean Tynan

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Mon, 12 May 2003 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Strange IsDate() problem with VB 3

2. ISDATE problem

3. Strange CDate and IsDate problem when run through WSF-file

4. Problem with IsDate function called within IIS/ ASP

5. IsDate function problem

6. VB 4.0 IsDate function - problems with local settings

7. ISDate

8. how to make isDate to work

9. IsDate too generous?

10. isdate working?

11. IsDate generating Exception inside of Try...Catch block

12. .net equivalent to IsDate()

 

 
Powered by phpBB® Forum Software