﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server Newbies  / Creating a BookingDate using a random function / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 18 May 2013 10:12:42 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Creating a BookingDate using a random function</title><link>http://www.sqlservercentral.com/Forums/Topic1422029-1292-1.aspx</link><description>[quote][b]ChrisM@Work (2/20/2013)[/b][hr][quote][b]wafw1971 (2/20/2013)[/b][hr]Its alright I have figured it out:...[/quote][url=http://www.sqlservercentral.com/Forums/FindPost1422013.aspx]DwainC already figured it out for you:[/url][code="sql"]SELECT 	ArrivalDate, 	BookingDate = DATEADD(day, 		-(1 + ABS(checksum(NEWID())) % 90),		ArrivalDate)  FROM BookingsORDER BY ArrivalDate[/code][/quote]I thought this looks familiar.  But in the other thread his boss has taken it to the next level. :-P</description><pubDate>Wed, 20 Feb 2013 17:59:06 GMT</pubDate><dc:creator>dwain.c</dc:creator></item><item><title>RE: Creating a BookingDate using a random function</title><link>http://www.sqlservercentral.com/Forums/Topic1422029-1292-1.aspx</link><description>[quote][b]wafw1971 (2/20/2013)[/b][hr]Its alright I have figured it out:...[/quote][url=http://www.sqlservercentral.com/Forums/FindPost1422013.aspx]DwainC already figured it out for you:[/url][code="sql"]SELECT 	ArrivalDate, 	BookingDate = DATEADD(day, 		-(1 + ABS(checksum(NEWID())) % 90),		ArrivalDate)  FROM BookingsORDER BY ArrivalDate[/code]</description><pubDate>Wed, 20 Feb 2013 05:46:13 GMT</pubDate><dc:creator>ChrisM@Work</dc:creator></item><item><title>RE: Creating a BookingDate using a random function</title><link>http://www.sqlservercentral.com/Forums/Topic1422029-1292-1.aspx</link><description>Its alright I have figured it out:SELECT ArrivalDate, DATEADD(day, -1 + RAND(checksum(NEWID()))*-90, ArrivalDate) AS BookingDate    FROM BookingsORDER BY ArrivalDate</description><pubDate>Wed, 20 Feb 2013 05:30:53 GMT</pubDate><dc:creator>wafw1971</dc:creator></item><item><title>Creating a BookingDate using a random function</title><link>http://www.sqlservercentral.com/Forums/Topic1422029-1292-1.aspx</link><description>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</description><pubDate>Wed, 20 Feb 2013 05:18:23 GMT</pubDate><dc:creator>wafw1971</dc:creator></item></channel></rss>