Randomising Dates

  • I have a Arrival date of 01/01/2012 the Departure date can be any date between 02/01/2012 and 29/01/2012 and needs to added to the database either via an Update/Insert Statement. Can you help with the code.

    Thanks

    Wayne

    SELECT ArrivalDate, DATEADD(day, RAND(checksum(NEWID()))

    * LengthOfStay.LengthofStay, ArrivalDate) AS DepartureDate

    FROM Bookings, LengthOfStay

    ORDER BY ArrivalDate

    But the Departure date cannot be the same as the arrival date.

Viewing 0 posts

You must be logged in to reply to this topic. Login to reply