Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Get records from start of calendar year to present

Author  Topic 

qman
Constraint Violating Yak Guru

442 Posts

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

Sounds simple.....

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

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

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-09-12 : 14:53:01
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
   

- Advertisement -