sql-string. Getting date in DBMS-style format

^date.sql-string[]
^date.sql-string[datetime|date|time]   
[3.4.2]

Without options or with option
datetime the method transforms the date into YYYY-MM-DD HH:MM:SS format, used by DBMS for storing dates. Using this method you can add date values to DB without any additional transformations.
If called with option
date the method transforms the date into YYYY-MM-DD format.
If called with option
time the method transforms the date into HH:MM:SS format.

Example
$now[^date::now[]]
^
connect[connect string]{
   ^
void:sql{insert into access_log (
      access_date
   
values (
      '
^now.sql-string[]
'
   
)}
}

We get string of format '
2001-11-30 13:09:56' with current date and time and at once place it into a DB field. Without this method at hand, we would have to put together the needed strings manually.
Note: the method doesn't form the apostrophes-you should add them by yourself.


Copyright © 1997–2017 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 17.06.2012