0
votes

Via power query I'm using a SQL query with a WHERE clause from certain discrete date to a second, further in time, discrete time. I would like to establish the second time something like the NOW() excel function.

VTBL1.DATE >= TO_DATE('19/08/2019 00:00:01','DD/MM/YYYY HH24:MI:SS')
AND VTBL1.DATE <= TO_DATE('21/08/2019 23:59:59','DD/MM/YYYY HH24:MI:SS')

VTBL1.DATE >= TO_DATE('19/08/2019 00:00:01','DD/MM/YYYY HH24:MI:SS')
AND VTBL1.DATE <= TO_DATE(NOW!)

Thanks!

1
Tag your question with the database yo are using.Gordon Linoff

1 Answers

0
votes

Your code looks like Oracle. Regardless of the database, though, you can simplify it -- the times are not necessary. In Oracle syntax, this looks like:

(VTBL1.DATE >= DATE '2018-08-19' AND 
 VTBL1.DATE < DATE '2019-08-22'
) OR
(VTBL1.DATE >= DATE '2019-08-19' AND 
 VTBL1.DATE < SYSDATE
)

Note: This ignores the fact that the two time frames overlap, so the code can be further simplified. I am guessing you really want '2018-08-22' for the second comparison.