~~NOCACHE~~

two function
 -  date.fromString(s, format) and then assign it or cast to any date/time type
 -  now() - to get current timestamp and then assign it or cast to any date/time type

sqldate sd = date.fromString('2011-01-02', 'yyyy-MM-dd’)

insert into ttest values(2, (sqltimestamp)date.fromString('2017-05-21 11:12:13', 'yyyy-MM-dd hh:mm:ss’))

To compare date/time columns you can also use cast operation.

 select * from ttest where (sqldate)ts = '2018-05-22’

select * from ttest where (sqldate)ts > '2018-05-22’

select * from ttest where ts < '2018-05-22 11:12:13.000’

select * from ttest where ts = '2017-05-21 11:12:13.000’

select * from ttest where ts = (sqltimestamp)date.fromString('2017-05-21 11:12:13', 'yyyy-MM-dd hh:mm:ss’)


SELECT * FROMtable
WHERE TODATE(timestamp) = '2012-05-05'
 
SELECT * FROM table
WHERE someTS BETWEEN '2012-05-05 00:00:00' AND '2012-05-05 23:59:59'
 
SELECT * FROM table WHERE someTS >= '2012-05-05 00:00:00' 
    AND someTS <= '2012-05-05 23:59:59'
 
SELECT * FROM table WHERE DATE(2012-05-05 00:00:00) = '2012-05-05'
 
SELECT *
FROM table
where someTS = timestamp('21.08.2017 09:31:57', 'dd-mm-yyyy hh24:mi:ss');
 
