I'm a bit stuck trying to generate random dates in the format 'yyyy-MM-dd' (e.g. '2013-12-31') for a varchar(10) column. I wonder if anyone can advise me on how to do this.
Firstly, am I right in thinking there is no date generator in this product? I couldn't find one. If I have missed it that could be an easy solution!
Anyway, I attempted to do it in a Python script:
Code: Select all
import datetime import random def main(config): random.seed(config["seed"]) some_date = random_date() return some_date def random_date(): earliest = datetime.date(1910,1,1) latest = datetime.date(2018,1,1) delta = latest - earliest int_delta = (delta.days * 24 * 60 * 60) + delta.seconds random_second = random.randrange(int_delta) return earliest + datetime.timedelta(seconds = random_second)
So, how can I get this to deliver different random dates for each row?
Any help would be much appreciated! Thank you.