Solved

SQL - Select 180 days from today (Query)

Posted on 2013-01-03
3
2,028 Views
Last Modified: 2013-01-03
I used dateadd(d,-180,GETDATE())  which pulls wrong date.

SELECT  dateadd(d,-180,GETDATE())
--2012-07-07 14:36:21.380


select * from Table1
Where startdate>= 180 days from Today.

Roughly from June month onwards ??
0
Comment
Question by:chokka
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
Steve Wales earned 500 total points
ID: 38741562
The date shown is correct.

July through December is 6 months - roughly 180 days.

Today is January 3rd.  Allowing for 365 days in a year, 7th of July is about 180 days ago.

If you want from the start of June onwards, you're talking 210 days give or take (216 days if you want to be accurate and starting from today).
0
 

Author Comment

by:chokka
ID: 38741634
okay great, thanks !! just had a doubt on my query !!
0
 

Author Closing Comment

by:chokka
ID: 38741635
Thanks
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now