Difference between pages "+ (string)" and "CURRENT DATE"

From SQLZOO
(Difference between pages)
Jump to: navigation, search
 
 
Line 1: Line 1:
 
<table align='right' border='1'>
 
<table align='right' border='1'>
 
<caption>Compatibility</caption>
 
<caption>Compatibility</caption>
<tr><th colspan='3'>s1 + s2</th></tr>
+
<tr><th colspan='3'>CURRENT_DATE</th></tr>
 
<tr><td align='center'>'''Engine'''</td><td align='center'>'''OK'''</td><td align='center'>'''Alternative'''</td></tr>
 
<tr><td align='center'>'''Engine'''</td><td align='center'>'''OK'''</td><td align='center'>'''Alternative'''</td></tr>
<tr><td align='left'>ingres</td><td>Yes</td><td></td></tr>
+
<tr><td align='left'>ingres</td><td>Yes</td><td>You must cast when using DBD::Ingres</td></tr>
<tr><td align='left'>mysql</td><td>No</td><td>[[CONCAT | CONCAT(s1,s2)]]</td></tr>
+
<tr><td align='left'>mysql</td><td>Yes</td><td></td></tr>
<tr><td align='left'>oracle</td><td>No</td><td>s1 || s2</td></tr>
+
<tr><td align='left'>oracle</td><td>Yes</td><td></td></tr>
<tr><td align='left'>postgres</td><td>No</td><td>s1 || s2</td></tr>
+
<tr><td align='left'>postgres</td><td>Yes</td><td></td></tr>
<tr><td align='left'>sqlserver</td><td>Yes</td><td></td></tr>
+
<tr><td align='left'>sqlserver</td><td>No</td><td>[[CURRENT_TIMESTAMP |CONVERT(CHAR(10),CURRENT_TIMESTAMP,126)]]</td></tr>
 
</table>
 
</table>
<h1> + (strings)</h1>
+
 
<p>+ allows you to stick two or more strings together. </p>
+
<h1>CURRENT_DATE</h1>
<p>This operation is concatenation.</p>  
+
<p>CURRENT_DATE returns today's date.</p>
 +
<p></p>  
 
<pre style='width:60ex'>
 
<pre style='width:60ex'>
   s1 + s2   
+
   CURRENT_DATE -> '2006-12-31'
 
</pre>
 
</pre>
  
<div class='ht'>
+
<div class='ht'>  
In this example you put the region and the name together for each country. 
+
<source lang='sql' class='def e-sqlserver'>
<source lang='sql' class='def e-oracle e-mysql'>
+
SELECT CURRENT_TIMESTAMP, whn
SELECT CONCAT(region,name)
+
   FROM eclipse
   FROM bbc
+
 
</source>
 
</source>
<source lang='sql' class='def e-oracle e-postgres'>
+
<source lang='sql' class='def e-oracle'>
SELECT region || name
+
SELECT CAST(CURRENT_DATE AS DATE),wk
   FROM bbc
+
   FROM gisq.totp
 
</source>
 
</source>
 
<source lang='sql' class='def'>
 
<source lang='sql' class='def'>
SELECT region + name
+
SELECT CAST(CURRENT_DATE AS DATE),wk
   FROM bbc
+
   FROM totp
 
</source>
 
</source>
 
</div>
 
</div>
Line 34: Line 34:
 
<p>See also</p>
 
<p>See also</p>
 
<ul>
 
<ul>
   <li>[[SUBSTRING |SUBSTRING function]]</li>
+
   <li>[[CURRENT_TIMESTAMP |CURRENT_TIMESTAMP function]]</li>
   <li>[[TRIM |TRIM function]]</li>
+
   <li>[[%2B(dates) |+(date) function]]</li>
 
</ul>
 
</ul>
  
 
{{Languages}}
 
{{Languages}}

Latest revision as of 18:33, 21 October 2012

Compatibility
CURRENT_DATE
EngineOKAlternative
ingresYesYou must cast when using DBD::Ingres
mysqlYes
oracleYes
postgresYes
sqlserverNoCONVERT(CHAR(10),CURRENT_TIMESTAMP,126)

CURRENT_DATE

CURRENT_DATE returns today's date.

   CURRENT_DATE -> '2006-12-31'
SELECT CURRENT_TIMESTAMP, whn
  FROM eclipse
SELECT CAST(CURRENT_DATE AS DATE),wk
  FROM gisq.totp
SELECT CAST(CURRENT_DATE AS DATE),wk
  FROM totp

See also

Language: English  • Deutsch
Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense