Name
stringdate — Convert a string to a datetime
Synopsis
stringdate
(
|
in
str
varchar
) ; |
Description
stringdate converts dates and timestamps from text to the internal DATETIME type.
The external format is: YYYY.MM.DD hh:mm.ss uuuuuu where uuuuuu represents number of microseconds.
If trailing parts are omitted from the string given to stringdate, they are assumed to be zero. The three first parts are mandatory. Note that use of
cast (x as datetime)
is preferred over this function.
Parameters
str
A varchar date in human-readable (external) format.
Errors
Table 24.80. Errors signalled by
datestring
and
stringdate
SQLState | Error Code | Error Text | Description |
---|---|---|---|
22007 | DT006 | Cannot convert <offending string> to datetime | |
22002 | DT007 | Nulls not allowed as parameters to stringdate |
Examples
Example 24.406. Stringdate example with datestring_GMT
We are at central european time zone CET(GMT+1).
SQL> use Demo; Done. -- 3 msec. SQL> select (datestring_GMT (stringdate ('2000-01-01 22:00'))); callret VARCHAR _______________________________________________________________________________ 2000-01-01 21:00:00.000000 1 Rows. -- 45 msec. SQL> select left (datestring(ShippedDate), 10) from Orders where ShippedDate > stringdate ('1996.6.3'); callret VARCHAR _______________________________________________________________________________ 1996-06-04 1996-06-04 1996-06-05 1996-06-05 1996-06-05 5 Rows. -- 3 msec.
See Also
The discussion of TIMESTAMP datatype in section Database Concepts of the documentation.