wafw1971 Posted February 19, 2013 Share Posted February 19, 2013 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.SELECT ArrivalDate, DATEADD(day, RAND(checksum(NEWID()))* LengthOfStay.LengthofStay, ArrivalDate) AS DepartureDate FROM Bookings, LengthOfStayORDER BY ArrivalDateBut the Departure date cannot be the same as the arrival date.Thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted February 19, 2013 Share Posted February 19, 2013 You just need to make sure you're adding at least one day to the arrival date, but that query doesn't look correct with regard to the length of stay value. You're telling it to get that from the other table but you're not telling it which row to get it from, it's going to always use the value from the first row. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now