Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #21977
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail |
|---|---|
| Content-Type | text/plain; charset="UTF-8" |
| Message-ID | <2514043.dTvkTq4YzN@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 01:57:15 +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> |
| MIME-Version | 1.0 |
| Lines | 51 |
| NNTP-Posting-Date | 12 Nov 2013 01:57:18 CET |
| NNTP-Posting-Host | 1f0ae3ac.newsspool2.arcor-online.net |
| X-Trace | DXC=iOB87b[;UDY[7Non7UCi8UA9EHlD;3YcR4Fo<]lROoRQ8kF<OcfhCO[5EF936Ae=FTDZm8W4\YJN\YUVHKH;GI^W\>@[hLNg?mY19MW?oN3[[U |
| X-Complaints-To | usenet-abuse@arcor.de |
| Xref | csiph.com comp.lang.javascript:21977 |
Show key headers only | View raw
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.
> 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.
> 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).
(Pseudo-)integers are safer, and you do not want to update the client-side
code when you change the database on the server.
[1] <http://PointedEars.de/scripts/test/date>
--
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
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