![]() |
|
|||||||
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
#1
IP: 112.87.30.158
|
|||
|
|||
|
For me I wanted a value between 2008 and 2009 (one year: 60 seconds * 60 minutes * 24 hours * 365 days = 31536000). Because the Unix timestamp doesn’t support fractions your need to round the value to an int. (floor or round the value).
Code:
SELECT FROM_UNIXTIME( UNIX_TIMESTAMP('2008-01-01 01:00:00')+FLOOR(RAND()*31536000)
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Insert/ Update random date in MySQL | Illiopolis | MySQL | 1 | 2015-04-19 06:18 AM |
| Random MySQL date | Kimberling City | MySQL | 1 | 2015-04-18 11:09 PM |
| MySQL Generate Random Date | Kensington | MySQL | 0 | 2015-04-18 11:02 PM |
| MySQL毫秒值和日期的指定格式的相互转换 | Kaitlin | MySQL | 0 | 2015-04-18 11:01 PM |
| mysql 帮助文档使用 | Haddam | MySQL | 0 | 2014-11-26 06:43 PM |