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


Groups > comp.lang.javascript > #21984

Re: Date to MS Access

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!uucp.gnuu.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail
Content-Type text/plain; charset="UTF-8"
Message-ID <1649164.xbWJDP9Hnm@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Organization PointedEars Software (PES)
Date Tue, 12 Nov 2013 13:21:30 +0100
User-Agent KNode/4.10.5
Content-Transfer-Encoding 8Bit
X-Face %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v
Face iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg==
Subject Re: Date to MS Access
Newsgroups comp.lang.javascript
References <j7ednQbAcdSE7BzPnZ2dnUVZ_uadnZ2d@westnet.com.au> <2514043.dTvkTq4YzN@PointedEars.de> <W-SdnWXwqfZnPxzPnZ2dnUVZ_rudnZ2d@westnet.com.au>
MIME-Version 1.0
Lines 68
NNTP-Posting-Date 12 Nov 2013 13:21:32 CET
NNTP-Posting-Host 27cb2b94.newsspool4.arcor-online.net
X-Trace DXC=4d?;UgKHml8kUFX=Y?aLP;4IUK<Cl32<14Fo<]lROoR18kF<OcfhCO;lY=Qggn==W?DZm8W4\YJN<YUVHKH;GI^7\>@[hLNg?m9Sj\BdL\HcR7
X-Complaints-To usenet-abuse@arcor.de
Xref csiph.com comp.lang.javascript:21984

Show key headers only | View raw


Andrew Poulos wrote:

> On 12/11/2013 11:57 AM, Thomas 'PointedEars' Lahn wrote:
>> Andrew Poulos wrote:
>>> I have an MS Access field of type Date/Time with no specific format set.
>>> Here Access dates appear in this type of format
>>>     12/11/2013 7:57:46 AM
>>>
>>> I need to take a date from the client side and pass it via a posted form
>>> to an ASP page running JScript.
>>>
>>> On the client I have
>>>     var nowDate = new Date();
>>>
>>> On the server I have
>>>
>>> var d = ... // nowDate retrieved from the form
>>
>> The part that is missing from your question is how you get “nowDate” into
>> the form.
> 
> I added nowDate.toISOString() as a value for a hidden input.

Can you rely on a conforming implementation of ECMAScript Ed. 5 or later?
 
> >> var SQLstr = "UPDATE myTable " +
> >>                "Set tbl_Date=#" + d +"# " +
> >>                "WHERE myID=1;";
> >
> > Hopefully you clean your input so that SQL injection like
> >
> >    d = "12/11/2013 7:57:46 AM#; DELETE myTable;"
> >      + " UPDATE myTable SET tbl_Date=12/11/2013 7:57:46 AM";
> >
> > is prevented.  The proper approach is Prepared Statements, but
> > apparently MS JetSQL does not support that; you could emulate it.
> 
> Yes.

Yes to what?

>>> Running it though results in a "500: Internal Server Error".
>>>
>>> How do I "format" the date on the client so that its valid SQL for
>>> Access?
>>
>> You could use Date.prototype.strftime("%d/%m/%Y %I:%M:%S %p") as provided
>> by JSX:string/date.js [1] on the client side, but I would strongly
>> recommend to pass a timestamp (Date.prototype.getTime()) and let the
>> server-side code do the SQL formatting (in which case I would be
>> interested to know if date.js worked there if there is no ASP-native
>> way).
> 
> I starting testing the Access function CDATE and passing it (yyyy-mm-d
> hours:minutes:seconds) which seems cumbersome

It also appears to be unsafe as it is still a string and code injection is 
possible.

> but I'll look into  using a timestamp instead.

ACK.
 
-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

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


Thread

Date to MS Access Andrew Poulos <ap_prog@hotmail.com> - 2013-11-12 11:05 +1100
  Re: Date to MS Access Andrew Poulos <ap_prog@hotmail.com> - 2013-11-12 11:34 +1100
  Re: Date to MS Access Christoph Michael Becker <cmbecker69@arcor.de> - 2013-11-12 01:35 +0100
  Re: Date to MS Access Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-12 01:57 +0100
    Re: Date to MS Access Andrew Poulos <ap_prog@hotmail.com> - 2013-11-12 14:38 +1100
      Re: Date to MS Access Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-12 13:21 +0100
        Re: Date to MS Access Andrew Poulos <ap_prog@hotmail.com> - 2013-11-12 23:42 +1100
  Re: Date to MS Access "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-11-11 17:41 -0800

csiph-web