• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 880
  • Last Modified:

Get SYSdate in SQL Server 2008 r2

I want to get t he sysdat and subtract 6 days from it
then put that date into a variable to use in my SELECT
so I only get order < Sdate
0
jaymz69
Asked:
jaymz69
3 Solutions
 
Ephraim WangoyaCommented:

declare @sdate datetime

set @sdate = DATEADD(DD, -6, GETDATE())
0
 
Paul JacksonCommented:
Declare @SDate DateTime
Select @SDate = DateAdd(d,-6, GetDate())
0
 
Ephraim WangoyaCommented:

or to remove the time portion as well

declare @sdate datetime

SET @sdate = DATEADD(DD, -6, DATEDIFF(DD, 0, GETDATE()))
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
dqmqCommented:
why use a variable?  

select ... from ... where order < Dateadd(dd,-6,datediff(dd,0,getdate()))
0
 
jaymz69Author Commented:
Even better if it can be done within the SELECT. I am going off my experance in another program, VFP
0
 
jaymz69Author Commented:
Thanks
0

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now