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 2005 Forums
 Transact-SQL (2005)
 How to insert a field in a date
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

matrixrep
Starting Member

30 Posts

Posted - 12/21/2011 :  15:29:50  Show Profile  Reply with Quote
Here is the problem:

SELECT YEAR.*
FROM YEAR inner join ORG
on YEAR.org = ORG.org
WHERE (getdate() BETWEEN YEAR.DATE_BEG AND YEAR.DATE_END)
and getdate() <= '2011-12-25'

I need to replace 2011 by an actual field in the table ORG which is
ORG.ACTUAL_YEAR ans leave the rest as it is.

How do i do that ?

Any help is deeply appreciated.

Season greetings to all

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 12/21/2011 :  15:44:14  Show Profile  Reply with Quote
and getdate() <= CAST(ORG.ACTUAL_YEAR AS VARCHAR(4)) + '-12-25'
or more preferably

and getdate() <= CAST(ORG.ACTUAL_YEAR AS VARCHAR(4)) + '1225'
Go to Top of Page

matrixrep
Starting Member

30 Posts

Posted - 12/21/2011 :  15:54:43  Show Profile  Reply with Quote
Thank you for your help.
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.06 seconds. Powered By: Snitz Forums 2000