# 22. Virtuoso Functions Guide - datestring, datestring_gmt,

Chapter Contents | Prev | Next
Keyword Search:
www.openlinksw.com
docs.openlinksw.com
Book Home
Contents
Preface
Virtuoso Functions Guide
Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
datestring, ...
curdate
dateadd
datediff
datestring_gmt
dayname
dayofmonth
dayofweek
dayofyear
dt_set_tz
get_timestamp
getdate
hour
minute
month
monthname
msec_time
now
quarter
second
stringdate
stringtime
timezone
week
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
Remote SQL Data Source
Replication
SOAP
SQL
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web Server & Internet
XML
XPATH & XQUERY
Functions Index

## datestring, datestring_gmt,

convert a datetime from internal to external date-time representation
datestring (in date datetime);
datestring_gmt (in date datetime);
Parameters
date – A datetime value.
Return values

datestring and datestring_GMT return a varchar.

Description

datestring and datestring_gmt convert timestamps or datetimes from internal to external date-time representation. The external representation is a human-readable ASCII string of up to 30 characters.

The external format is: YYYY-MM-DD hh:mm:ss uuuuuu where uuuuuu represents microseconds.

Note:

Using cast (dt as varchar) is preferred over datestring.

Examples
Simple Example

Get current date in human-readable form.

     SQL> select datestring(now());
     callret
     VARCHAR
     _______________________________________________________________________________

     2001-03-01 12:49:59.000000

     1 Rows. -- 585 msec.

A table query example

Get orders shipped later than July 3, 1996

     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

datestring_gmt, stringdate

The discussion of TIMESTAMP datatype in section Database Concepts of the documentation.