Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #24065

Re: Date false

From Joao Rodrigues <groups_jr-1@yahoo.com.br>
Newsgroups comp.lang.javascript
Subject Re: Date false
Date 2014-05-09 18:05 -0300
Organization Aioe.org NNTP Server
Message-ID <lkjftq$1m8$1@speranza.aioe.org> (permalink)
References <1JidnUNwV7viyvHOnZ2dnUVZ_t6dnZ2d@westnet.com.au>

Show all headers | View raw


Em 09/05/2014 01:18, Andrew Poulos escreveu:
> I'm use JScript with ASP to read a db
>
> // if there's no error, d can either be a date or 0 (zero)
> var d = e = rs("ExpiryDay").value;

Unless you have declared the "e" variable previously, the above code 
would declare a new global variable named "e". E.g.

function doSomething() {
   var i = j = 0;
   var len = len2 = 0;
   var aux = aux2 = '';

   // i, len and aux are local variables (function scope),
   // whereas j, len2 and aux2 are global variables (declared implicitly)
   // ...
}


>
> Then I use it in an if statement
>
> if (d) {
>    // 'do something'
> }
>
> even when
>    window.alert(d +" + "+ (typeof d));
> displays
>    Thu May 14 00:00:00 UTC 1000 2015 + date
> 'do something' never happens.
>
> I'm confused. Can a date be false?

I have found weird errors / problems in classic ASP with JScript and 
mySQL. For instance, if I don't use CursorLocation = 3 (adUseClient), 
RecordCount would always return -1.

var rset = Server.CreateObject("ADODB.Recordset");
rset.CursorLocation = 3; // avoids RecordCount returning -1

So, I'd suggest using a specific function to test for valid dates:

   if (isDate(rs("ExpiryDay").Value)) { }


-- 
Joao Rodrigues (J.R.)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Date false Andrew Poulos <ap_prog@hotmail.com> - 2014-05-09 14:18 +1000
  Re: Date false Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-09 10:46 +0200
  Re: Date false "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-05-09 10:58 +0200
  Re: Date false Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-09 11:01 +0200
  Re: Date false Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-05-09 17:27 -0300
    Re: Date false Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-05-09 17:32 -0300
    Re: Date false Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-10 10:36 +0200
  Re: Date false Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-05-09 18:05 -0300

csiph-web