sql - Departure Date after Arrival Date -
this simple reply don't know it, how create sure departure after arrival date.
thanks
wayne
dateadd(day, abs(checksum(newid()) % 365), '1 jan 2010') arrivaldate, dateadd(day, abs(checksum(newid()) % 365), '1 jan 2010') depaturedate,
you can check using datediff ('day', depaturedate, arrivaldate)
.
this way can subtract arrivaldate depaturedate. if negative answer, depaturedate before arrivaldate.
have @ link:
datediff
edit:
declare @var1 int; declare @var2 int; set @var1 = abs(checksum(newid()) % 365); set @var2 = abs(checksum(newid()) % (365-@var1)); select @var1, @var2, dateadd(day, @var1, '1 jan 2010') arrivaldate, dateadd(day, @var2, dateadd(day, @var1, '1 jan 2010')) depaturedate
sql date
No comments:
Post a Comment