NaviServer - programmable web server
4.99  5.0

[ Main Table Of Contents | Table Of Contents | Keyword Index ]

ns_buildsqldate(n) 4.99.30 nsdb "NaviServer Module Commands"

Name

ns_buildsqldate - SQL date and time manipulation commands

Table Of Contents

Synopsis

Description

The following commands build SQL dates and timestamps for inclusion in SQL queries.

COMMANDS

ns_buildsqldate month day year

This command builds a SQL date string out of the specified month, day, and year. The month can be the month number (1 - 12) or the full, capitalized month name (January, February, ..., December). The day must be a number from 1 - 31, and the year must be a 4-digit year (e.g., 1957). An error is returned if any of the argument values are invalid. The resulting string can be used in an SQL statement.

ns_localsqltimestamp

This command returns a timestamp value that encodes the local time in ANSI SQL format (YYYY-MM-DD hh24:mm:ss).

EXAMPLES

% ns_buildsqldate "01" "15" "1929"
1929-01-15
% ns_buildsqldate "13" "31" "2000"
Invalid date: 13 31 2000
while executing ...
% ns_localsqltimestamp
2020-02-11 11:23:38

This command is equivalent to the following:

% ns_fmttime [clock seconds] "%Y-%m-%d %H:%M:%S"
% clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S"

See Also

ns_db, ns_fmttime

Keywords

SQL, database, date, time