Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vertica DB: Need to use a date string and convert as part of where clause

Tags:

vertica

I have a field in vertica

deviceReceiptTime   -5  Integer 19  8

It appears to hold milliseconds

1504828819089
1504828819071

Epoch date  Human readable date (GMT) 
1504828819  2017-09-08 00:00:19

I would like the analyst to be able to enter a standard date format like YYYY-MMDD HH24MISS instead of converting to milliseconds first.

instead of

where deviceReceiptTime Between 1490270439780 and 1490270448888
like image 277
Chief Avatar asked Jan 28 '26 06:01

Chief


1 Answers

Maybe something like this...

where deviceReceiptTime between 
    extract ( epoch from <lower_limit ) and 
    extract ( epoch from <higher_limit> )

For example:

where deviceReceiptTime between 
    extract ( epoch from '2017-02-08 00:00:00'::timestamp ) and 
    extract ( epoch from '2017-04-08 00:00:00'::timestamp )
like image 116
mauro Avatar answered Jan 30 '26 21:01

mauro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!