Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Randomising Dates Expand / Collapse
Author
Message
Posted Tuesday, February 19, 2013 7:19 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, May 07, 2013 3:30 AM
Points: 62, Visits: 155
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.

Post #1421640
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse