Search
 
SCRIPT & CODE EXAMPLE
 

SQL

create date sql

-- SQL Server
SELECT cast(cast(@year*10000 + @month*100 + @day as varchar(255)) as date)
-- Oracle:TO_DATE(string, format)
SELECT TO_DATE('2012-06-05', 'YYYY-MM-DD') FROM dual;
SELECT TO_DATE('05/06/2012 13:25:12', 'DD/MM/YYYY HH24:MI:SS') FROM dual;
-- SQL Server: CONVERT(data_type, string, style). Cf source link for style codes.
SELECT datefromparts(@year, @month, @day)
SELECT CONVERT(DATETIME, '2012-06-05', 102);	  -- Raises error if impossible
SELECT TRY_CONVERT(DATETIME, '2012-06-05', 102);  -- Returns Null if impossible
-- MySQL: STR_TO_DATE(string, format): 
SELECT STR_TO_DATE('2012-06-05','%Y-%m-%d');
Comment

PREVIOUS NEXT
Code Example
Sql :: mysql order by two columns priority 
Sql :: division by zero postgres 
Sql :: select distinct postgres 
Sql :: get number of columns sql 
Sql :: show sql server database 
Sql :: mysql count by month 
Sql :: how to change db owner postgres 
Sql :: mysql load sql from file 
Sql :: Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF 
Sql :: sql server drop column 
Sql :: sql server drop database 
Sql :: sql select lowest value row 
Sql :: mysql set boolean default value 
Sql :: SQL Add Column in a Table 
Sql :: view table mysql 
Sql :: sqlite insert or update 
Sql :: mysql import database 
Sql :: sql datitime to date 
Sql :: sql server delete table 
Sql :: oracle change tablespace size 
Sql :: get largest number in database sql 
Sql :: SQL column name Oracle 
Sql :: multiple count with where clause sql 
Sql :: import data from csv to sql server 
Sql :: ignore case in string sql 
Sql :: oracle sql number to varchar2 
Sql :: Which MySQL data type to use for storing boolean values 
Sql :: oracle get ddl 
Sql :: unique in sql server 
Sql :: mysql limit order by 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =