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 2005 Forums
 Transact-SQL (2005)
 Tsql of Date

Author  Topic 

IBoonZ
Yak Posting Veteran

53 Posts

Posted - 2009-03-13 : 05:08:43
Hi

Can someone help me with following problem:

i have 2 collums, the one is with 1 and 0, these mean : if it is a 1 its a permanent product, if it is 0 its a trial version.

When it is 0 we have the second collum and in that collum the expiration date is in it.

Now i need a TSQL that tells me in a new collum, when i link it to my time dimension. That in 30 days that product is going to expire. I tried alot of possibilitys, but i dont get the right data

Thanks in advance

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-03-13 : 05:10:47
SELECT * FROM Table1
WHERE Col1 = 1
OR Col2 >= GETDATE() AND Col2 < DATEADD(DAY, 30, GETDATE())



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

IBoonZ
Yak Posting Veteran

53 Posts

Posted - 2009-03-13 : 05:18:01
And I thank you very much :)
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-03-13 : 05:52:03
SELECT * FROM Table1
WHERE Col1 = 1
OR Col2 BETWEEN GETDATE() AND DATEADD(DAY, 30, GETDATE())




E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

IBoonZ
Yak Posting Veteran

53 Posts

Posted - 2009-03-13 : 06:23:46
Is there a possibility to create these values in a new collumn? Cus when i try to link them to my
fact table, i get an error, because the where function ingores the trial versions that are older then 30 days.
Or do you have a better solution?


Kind Regards
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-03-13 : 06:28:37
Please post table structure and some proper sample data.
If you need help with that, please read http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
and http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -