SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Get records from start of calendar year to present
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

qman
Constraint Violating Yak Guru

USA
422 Posts

Posted - 09/12/2012 :  14:49:08  Show Profile  Reply with Quote
Based on today's date, how can I select all records from begining of the year up to current date...?

Sounds simple.....

sunitabeck
Flowing Fount of Yak Knowledge

5152 Posts

Posted - 09/12/2012 :  14:51:02  Show Profile  Reply with Quote
SELECT *
FROM   YourTable
WHERE  datecolumn >= DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()), 0)
       AND datecolumn <= GETDATE();
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47188 Posts

Posted - 09/12/2012 :  14:53:01  Show Profile  Reply with Quote
quote:
Originally posted by qman

Based on today's date, how can I select all records from begining of the year up to current date...?

Sounds simple.....


see

http://visakhm.blogspot.com/2010/01/some-quick-tips-for-date-formating.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000