|
wafw1971
Yak Posting Veteran
68 Posts |
Posted - 02/20/2013 : 07:16:40
|
I have an arrival date already in the system and I need to populate the Booking date using a random function, the booking date can be any day on or before the arrival date up to a maximum 90 days previous but it must be random the booking date cannot all be the same date.
I thought I cracked it but was wrong. Can you help?
SELECT ArrivalDate, DATEADD(day, -1 + RAND(checksum(NEWID()))-90 , ArrivalDate) AS BookingDate FROM Bookings ORDER BY ArrivalDate
Thanks
Wayne |
|
|
wafw1971
Yak Posting Veteran
68 Posts |
Posted - 02/20/2013 : 07:31:23
|
Its alright I have figured it out:
SELECT ArrivalDate, DATEADD(day, -1 + RAND(checksum(NEWID()))*-90 , ArrivalDate) AS BookingDate FROM Bookings ORDER BY ArrivalDate |
 |
|