Solved

SQL - Select 180 days from today (Query)

Posted on 2013-01-03
3
2,370 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 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
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, 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.

631 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