简体   繁体   中英

randomizing timestamp without timezone in postgresql

Is there any way to randomize a timestamp without timezone with an interval of within 1hour? For example:

event_start = '2019-10-31 13:00:00'
event_end = '2019-10-31 14:00:00'

but can also be

event_start = '2019-10-31 13:00:00'
event_end = '2019-10-31 13:40:59'

you can add a random number of minutes to your timestamp:

timestamp '2019-10-31 13:00:00' + make_interval(mins => (random() * 59)::int)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM