I have two dates as strings (dd-mm-yyyy). How can I get a random date between these two dates?
You can convert dates to a Unix timestamp. Randomly select a timestamp between two timestamps and convert it back.
Convert dates to fixed numbers such as Julian values (name them J1 and J2). Generate a "random" number from 0 <= N <= J2-j1. Then convert J1 + N from Julian back to date.
3 : d1 = dd, m1 = mm, y1 = yyyy, d2, m2, y2
, , (http://www.cprogramming.com/tutorial/random.html), y1 y2, . dd 1 28 1 12. 28. , , , ( , , , , 29 ).
int a b, :
int random = a + rand() % (b - a + 1);
, y1 = y2 m1 = m2,
Use the types and functions from the standard time.h library:
http://en.wikipedia.org/wiki/Time.h
Convert the string details to int and then convert them to time_t. After calculating your random value between them, go another way to get the result in a row.
Source: https://habr.com/ru/post/1735255/More articles:The flat file connection manager in the SSIS package shows that "A valid file name must be selected" - visual-studio-2008The compiler complains about BOOST_CHECK_THROW on the constructor - c ++Have a linux shell script enter a line into the windows user copy / paste buffer - linuxjoin of two tables - sqlCan I embed a Bytecode inside my source code? - javahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1735256/extjs-how-can-i-add-event-handlers-to-a-component-in-its-raw-object-form-xtype&usg=ALkJrhgS-gmDrWdlKgWJ3cgxFMgiLSejkgIs there a way to save reassembled TCP in Wireshark - httpТестирование файлов js.erb в рельсах - javascriptIs there a version of CPAN in Python? - pythonКак я могу читать данные excel (office 2007 xlsx) в PHP? - phpAll Articles