Difference between revisions of "Format dates"

From SQLZOO
Jump to: navigation, search
(Created page with "Format a date and time. <div class='ht'> <div class=params>schema:gisq</div> <div> Many engines support the SQL standard - see Mimer for details. </div> <source lang=sql class...")
 
 
Line 36: Line 36:
 
  WHERE singer='Tom Jones'</source>
 
  WHERE singer='Tom Jones'</source>
 
<source lang='sql' class='def e-oracle'>SELECT TO_CHAR(wk, 'DD/MM/YYYY'), song
 
<source lang='sql' class='def e-oracle'>SELECT TO_CHAR(wk, 'DD/MM/YYYY'), song
FROM totp
+
FROM gisq.totp
 
WHERE singer='Tom Jones'</source>
 
WHERE singer='Tom Jones'</source>
 
<source lang='sql' class='def e-sqlserver'>SELECT CONVERT(VARCHAR(10), wk, 103), song
 
<source lang='sql' class='def e-sqlserver'>SELECT CONVERT(VARCHAR(10), wk, 103), song

Latest revision as of 16:15, 17 July 2012

Format a date and time.

schema:gisq

Many engines support the SQL standard - see Mimer for details.

 
 
SELECT STRFTIME('%d/%m/%Y', wk), song
 FROM totp
 WHERE singer='Tom Jones'
SELECT CHAR(wk, eur),
       song
 FROM totp
 WHERE singer='Tom Jones'
SELECT CAST(EXTRACT(DAY FROM wk) AS VARCHAR(2))
       || '/' ||
       CAST(EXTRACT(MONTH FROM wk) AS VARCHAR(2))
       || '/' ||
       CAST(EXTRACT(YEAR FROM wk) AS VARCHAR(4)),
       song
 FROM totp
 WHERE singer='Tom Jones'
SELECT FORMAT(wk, 'DD/MM/YYYY'),
       song
 FROM totp
 WHERE singer='Tom Jones'
SELECT CAST(EXTRACT(DAY FROM wk) AS VARCHAR(2))
       || '/' ||
       CAST(EXTRACT(MONTH FROM wk) AS VARCHAR(2))
       || '/' ||
       CAST(EXTRACT(YEAR FROM wk) AS VARCHAR(4)),
       song
 FROM totp
 WHERE singer='Tom Jones'
SELECT TO_CHAR(wk, 'DD/MM/YYYY'), song
FROM gisq.totp
WHERE singer='Tom Jones'
SELECT CONVERT(VARCHAR(10), wk, 103), song
  FROM totp
 WHERE singer='Tom Jones'
SELECT DATE_FORMAT(wk,'%d/%m/%Y'), song
FROM totp
WHERE singer='Tom Jones'
SELECT CAST(EXTRACT(DAY FROM wk) AS VARCHAR(2))
       || '/' ||
       CAST(EXTRACT(MONTH FROM wk) AS VARCHAR(2))
       || '/' ||
       CAST(EXTRACT(YEAR FROM wk) AS VARCHAR(4)),
       song
 FROM totp
 WHERE singer='Tom Jones'
SELECT CAST(EXTRACT(DAY FROM wk) AS VARCHAR(2))
       || '/' ||
       CAST(EXTRACT(MONTH FROM wk) AS VARCHAR(2))
       || '/' ||
       CAST(EXTRACT(YEAR FROM wk) AS VARCHAR(4)),
       song
 FROM totp
 WHERE singer='Tom Jones'
Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense