Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Date Between (Start & Now)

Tags:

sql

presto

Not sure how to use the NOW() function in presto. Seems like it should be straight forward, but i'm getting no luck

SELECT DISTINCT field
FROM table
WHERE field BETWEEN '2019-01-01' and NOW()

field = varchar

like image 989
urdearboy Avatar asked Aug 16 '19 19:08

urdearboy


1 Answers

You should match data types to avoid implicit conversions:

SELECT DISTINCT field
FROM table
WHERE CAST(field AS DATE) BETWEEN DATE '2019-01-01' AND CURRENT_DATE;

SELECT DISTINCT field
FROM table
WHERE DATE(field) BETWEEN DATE '2019-01-01' AND CURRENT_DATE;
like image 182
Lukasz Szozda Avatar answered Oct 17 '22 14:10

Lukasz Szozda