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

matrixrep
Starting Member

29 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

29 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  
 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.08 seconds. Powered By: Snitz Forums 2000