Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #23042 > unrolled thread
| Started by | Andrew Poulos <ap_prog@hotmail.com> |
|---|---|
| First post | 2014-02-10 10:09 +1100 |
| Last post | 2014-02-10 21:16 +1100 |
| Articles | 5 — 2 participants |
Back to article view | Back to comp.lang.javascript
Confusion over date Andrew Poulos <ap_prog@hotmail.com> - 2014-02-10 10:09 +1100
Re: Confusion over date "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-02-10 00:54 +0100
Re: Confusion over date Andrew Poulos <ap_prog@hotmail.com> - 2014-02-10 14:30 +1100
Re: Confusion over date "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-02-10 09:56 +0100
Re: Confusion over date Andrew Poulos <ap_prog@hotmail.com> - 2014-02-10 21:16 +1100
| From | Andrew Poulos <ap_prog@hotmail.com> |
|---|---|
| Date | 2014-02-10 10:09 +1100 |
| Subject | Confusion over date |
| Message-ID | <McWdncG4nIe8lmXPnZ2dnUVZ_tednZ2d@westnet.com.au> |
I'm using jscript in classic ASP to query an SQLServer for a date
var expiry = rs.Fields("ExpiryDay").value;
If I put the variable into the page with
<%= expiry %>
I get
Mon Feb 10 09:58:15 UTC+1100 2014
Yet this
if (expiry) {
// has date
} else {
// does NOT have date
}
keeps returning "does NOT have date".
I thought that only
undefined, null, NaN, 0, "", and false
were falsey, so why is 'expiry' false?
Andrew Poulos
[toc] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2014-02-10 00:54 +0100 |
| Message-ID | <XnsA2D0942C480Ceejj99@194.109.133.133> |
| In reply to | #23042 |
Andrew Poulos <ap_prog@hotmail.com> wrote on 10 feb 2014 in
comp.lang.javascript:
> I'm using jscript in classic ASP to query an SQLServer for a date
> var expiry = rs.Fields("ExpiryDay").value;
>
> If I put the variable into the page with
> <%= expiry %>
> I get
> Mon Feb 10 09:58:15 UTC+1100 2014
>
> Yet this
>
> if (expiry) {
Some say you need to explicitly create a Date object.
var expiry = new Date(rs("ExpiryDay").Value);
Try some debugging with this.
> // has date
>} else {
> // does NOT have date
>}
>
> keeps returning "does NOT have date".
Not strictly true
// does NOT have date
won't return a thing.
> I thought that only
> undefined, null, NaN, 0, "", and false
> were falsey, so why is 'expiry' false?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Andrew Poulos <ap_prog@hotmail.com> |
|---|---|
| Date | 2014-02-10 14:30 +1100 |
| Message-ID | <n_CdncEWieq81WXPnZ2dnUVZ_smdnZ2d@westnet.com.au> |
| In reply to | #23043 |
On 10/02/2014 10:54 AM, Evertjan. wrote:
> Andrew Poulos <ap_prog@hotmail.com> wrote on 10 feb 2014 in
> comp.lang.javascript:
>
>> I'm using jscript in classic ASP to query an SQLServer for a date
>> var expiry = rs.Fields("ExpiryDay").value;
>>
>> If I put the variable into the page with
>> <%= expiry %>
>> I get
>> Mon Feb 10 09:58:15 UTC+1100 2014
>>
>> Yet this
>>
>> if (expiry) {
>
> Some say you need to explicitly create a Date object.
>
> var expiry = new Date(rs("ExpiryDay").Value);
>
> Try some debugging with this.
Thanks, creating a Date object gave me predictable results.
Andrew Poulos
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2014-02-10 09:56 +0100 |
| Message-ID | <XnsA2D065211FFA9eejj99@194.109.133.133> |
| In reply to | #23044 |
Andrew Poulos <ap_prog@hotmail.com> wrote on 10 feb 2014 in
comp.lang.javascript:
> On 10/02/2014 10:54 AM, Evertjan. wrote:
>> Andrew Poulos <ap_prog@hotmail.com> wrote on 10 feb 2014 in
>> comp.lang.javascript:
>>
>>> I'm using jscript in classic ASP to query an SQLServer for a date
>>> var expiry = rs.Fields("ExpiryDay").value;
>>>
>>> If I put the variable into the page with
>>> <%= expiry %>
>>> I get
>>> Mon Feb 10 09:58:15 UTC+1100 2014
>>>
>>> Yet this
>>>
>>> if (expiry) {
>>
>> Some say you need to explicitly create a Date object.
>>
>> var expiry = new Date(rs("ExpiryDay").Value);
>>
>> Try some debugging with this.
>
> Thanks, creating a Date object gave me predictable results.
Probably, like the .Fields, the .Value is default too:
var doomsday = new Date(rs("DoomsDay"));
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Andrew Poulos <ap_prog@hotmail.com> |
|---|---|
| Date | 2014-02-10 21:16 +1100 |
| Message-ID | <EaudnSFgU6LzOmXPnZ2dnUVZ_gadnZ2d@westnet.com.au> |
| In reply to | #23045 |
On 10/02/2014 7:56 PM, Evertjan. wrote:
> Andrew Poulos <ap_prog@hotmail.com> wrote on 10 feb 2014 in
> comp.lang.javascript:
>
>> On 10/02/2014 10:54 AM, Evertjan. wrote:
>>> Andrew Poulos <ap_prog@hotmail.com> wrote on 10 feb 2014 in
>>> comp.lang.javascript:
>>>
>>>> I'm using jscript in classic ASP to query an SQLServer for a date
>>>> var expiry = rs.Fields("ExpiryDay").value;
>>>>
>>>> If I put the variable into the page with
>>>> <%= expiry %>
>>>> I get
>>>> Mon Feb 10 09:58:15 UTC+1100 2014
>>>>
>>>> Yet this
>>>>
>>>> if (expiry) {
>>>
>>> Some say you need to explicitly create a Date object.
>>>
>>> var expiry = new Date(rs("ExpiryDay").Value);
>>>
>>> Try some debugging with this.
>>
>> Thanks, creating a Date object gave me predictable results.
>
> Probably, like the .Fields, the .Value is default too:
>
> var doomsday = new Date(rs("DoomsDay"));
I just did a test and it appears that it doesn't need the ".Fields" but
does need the ".value" with a lower case vee- very strange.
Andrew Poulos
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web