Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
wafw1971
Yak Posting Veteran
75 Posts |
Posted - 2013-02-20 : 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 ArrivalDateThanks Wayne |
|
wafw1971
Yak Posting Veteran
75 Posts |
Posted - 2013-02-20 : 07:31:23
|
Its alright I have figured it out:SELECT ArrivalDate, DATEADD(day, -1 + RAND(checksum(NEWID()))*-90, ArrivalDate) AS BookingDate FROM BookingsORDER BY ArrivalDate |
|
|
|
|
|