Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL - Select 180 days from today (Query)

Posted on 2013-01-03
3
Medium Priority
?
2,481 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
Steve Wales earned 2000 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

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

722 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