Difference between revisions of "DAY"

From SQLZOO
Jump to: navigation, search
 
(4 intermediate revisions by one user not shown)
Line 5: Line 5:
 
<tr><td align='left'>ingres</td><td>No</td><td>[[EXTRACT |EXTRACT(DAY from d)]]</td></tr>
 
<tr><td align='left'>ingres</td><td>No</td><td>[[EXTRACT |EXTRACT(DAY from d)]]</td></tr>
 
<tr><td align='left'>mysql</td><td>Yes</td><td>[[EXTRACT |EXTRACT(DAY from d)]]</td></tr>
 
<tr><td align='left'>mysql</td><td>Yes</td><td>[[EXTRACT |EXTRACT(DAY from d)]]</td></tr>
<tr><td align='left'>oracle</td><td>No</td><td>[[TO_CHAR(d,'DD')]]</td></tr>
+
<tr><td align='left'>oracle</td><td>No</td><td>[[TO_CHAR(dates) |TO_CHAR(d,'DD')]]</td></tr>
 
<tr><td align='left'>postgres</td><td>No</td><td>[[EXTRACT |EXTRACT(DAY from d)]]</td></tr>
 
<tr><td align='left'>postgres</td><td>No</td><td>[[EXTRACT |EXTRACT(DAY from d)]]</td></tr>
 
<tr><td align='left'>sqlserver</td><td>Yes</td><td>[[DATEPART |DATEPART(DAY,d)]]</td></tr>
 
<tr><td align='left'>sqlserver</td><td>Yes</td><td>[[DATEPART |DATEPART(DAY,d)]]</td></tr>
 
</table>
 
</table>
 +
 
<h1>DAY</h1>
 
<h1>DAY</h1>
 
<p>DAY allows you to retrieve the day from a date.</p>
 
<p>DAY allows you to retrieve the day from a date.</p>
Line 34: Line 35:
 
       ,whn
 
       ,whn
 
       ,wht
 
       ,wht
   FROM eclipse
+
   FROM gisq.eclipse
 
</source>
 
</source>
 
<source lang='sql' class='def'>
 
<source lang='sql' class='def'>
Line 47: Line 48:
 
<ul>
 
<ul>
 
   <li>[[EXTRACT |EXTRACT function]]</li>
 
   <li>[[EXTRACT |EXTRACT function]]</li>
   <li>[[ +(date) function]]</li>
+
   <li>[[%2B(dates) |+(date) function]]</li>
   <li>[[MONTH function]]</li>
+
   <li>[[MONTH |MONTH function]]</li>
   <li>[[HOUR function]]</li>
+
   <li>[[HOUR |HOUR function]]</li>
   <li>[[MINUTE function]]</li>
+
   <li>[[MINUTE |MINUTE function]]</li>
   <li>[[SECOND function]]</li>
+
   <li>[[SECOND |SECOND function]]</li>
 
</ul>
 
</ul>
 +
 +
{{Languages}}

Latest revision as of 18:02, 21 October 2012

Compatibility
DAY(d)
EngineOKAlternative
ingresNoEXTRACT(DAY from d)
mysqlYesEXTRACT(DAY from d)
oracleNoTO_CHAR(d,'DD')
postgresNoEXTRACT(DAY from d)
sqlserverYesDATEPART(DAY,d)

DAY

DAY allows you to retrieve the day from a date.

   DAY(d)

In this example you get the day from the date field whn.

SELECT EXTRACT(DAY FROM whn) AS v
      ,whn
      ,wht
  FROM eclipse
SELECT EXTRACT(DAY FROM whn) AS v
      ,whn
      ,wht
  FROM eclipse
SELECT TO_CHAR(whn,'DAY') AS v
      ,whn
      ,wht
  FROM gisq.eclipse
SELECT DAY(whn) AS v
      ,whn
      ,wht
  FROM eclipse

See also

Language: English  • Deutsch
Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense