SELECT date_trunc('hour', $1) + (cast(($2::varchar||' min') as interval) * round( (date_part('minute',$1)::float + date_part('second',$1)/ 60.)::float / cast($2 as float)))ĬREATE OR REPLACE FUNCTION floor_minutes( TIMESTAMP WITHOUT TIME ZONE, integer ) RETURNS TIMESTAMP WITHOUT TIME ZONE AS $$ CREATE OR REPLACE FUNCTION round_minutes( TIMESTAMP WITHOUT TIME ZONE, integer) This here are my sets of functions that will round, floor, and ceiling timestamps. In trying to use Peter's answer above to create ceiling and floor functions I found that you have to take into account the seconds too when calling the rounding function. Mysql Workbench composite key in diagram.How to reorder records / rows in a MySQL table.How to do a one-time load for 4 billion records from MySQL to SQL Server.InstantObjects looks good, but I can't find any code to use MySQL with it.How to see if result of SQL query is empty before performing other queries in PHP.convert SQL query to query builder style. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |