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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | 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)
 month number and year number where condition betwe
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cplusplus
Aged Yak Warrior

567 Posts

Posted - 11/25/2012 :  17:25:22  Show Profile  Reply with Quote
Is it possible to between dates of whole month, if i pass just month number and year.

If i pass 10 & 2012

Can this be done:

where reg_dt_tm BETWEEN to_date('10/01/2012', 'MM/DD/YYYY') AND to_date('10/31/2012',
'MM/DD/YYYY')

or

If i pass 11 & 2012

where reg_dt_tm BETWEEN to_date('11/01/2012', 'MM/DD/YYYY') AND to_date('11/30/2012',
'MM/DD/YYYY')


Thanks for the helpful info.

jimf
Flowing Fount of Yak Knowledge

USA
2875 Posts

Posted - 11/25/2012 :  17:42:17  Show Profile  Reply with Quote
WHERE reg_dt >= DATEADD (month,@month-1, DATEADD(year,@year-1900,'19000101')) and reg_dt < DATEADD (month,@month, DATEADD(year,@year-1900,'19000101))

There is no to_date in sql server.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
  Previous Topic Topic Next 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