Timestamp truncation in MonetDB
Hi, I'm trying to truncate timestamp value to hour and/or minute precision. I combined cast and extract functions as: Problem: Truncate '2013-08-12 23:59:59' to '2013-08-12 23:00:00' select cast(timestamp '2013-08-12 23:59:59' as date)||' '||extract(hour from timestamp '2013-08-12 23:59:59')||':00:00'; Output: 2013-08-12 23:00:00 But this is expensive because of repeated function calls. Is there any faster and built-in function? Regards, Ravi
There is no such function built in. Its why people also redundantly store temporal values with the proper granularity. Then this cost is at least be carried once /tuple. regards, Martin On 8/13/13 6:20 PM, Ravikumar Balasubramaniam wrote:
Hi,
I'm trying to truncate timestamp value to hour and/or minute precision. I combined cast and extract functions as:
Problem: Truncate '2013-08-12 23:59:59' to '2013-08-12 23:00:00'
select cast(timestamp '2013-08-12 23:59:59' as date)||' '||extract(hour from timestamp '2013-08-12 23:59:59')||':00:00'; Output: 2013-08-12 23:00:00
But this is expensive because of repeated function calls. Is there any faster and built-in function?
Regards, Ravi
_______________________________________________ users-list mailing list users-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/users-list
participants (2)
-
Martin Kersten
-
Ravikumar Balasubramaniam