Click here to Skip to main content
15,893,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,,


for my application

i want to check the scheme before the Valid_From_Date also and also to restrict to retrive if the date is after the expiration of Valid_To_Date..
SQL
select (case when Deposit_Type =1 then 'RD' else 'FD' end) as Deposit_Type,
        ID,
        Scheme_Name,
        (case when Mode_Operation=1 then 'General' else 'SC' end)as Mode_Operation,
        Period_Type,
        Period_Value,
        Type_Interest,
        Interest_Rate,
        LockIn_Period,
        PNL_Interest,  
        Is_Active from Scheme WHERE GETDATE() BETWEEN Valid_From_Date AND Valid_To_Date
Posted
Updated 5-Aug-12 20:59pm
v2
Comments
OriginalGriff 6-Aug-12 3:00am    
And?
What problem are you having?
sk. maqdoom ali 6-Aug-12 3:18am    
I WANT TO GET RETRIVE THE DATA BEFORE THE DAY OF Valid_From_Date ex;Valid_From_Date = 12-08-2012 then for 11-08-2012 also i want to retrive the data
and also
not to retrive data Valid_To_Date which is expired before . for ex:Valid_To_Date = 12-07-2012 if we check it today this Valid_To_Date data must not be retrived
OriginalGriff 6-Aug-12 3:25am    
Did I ask you to shout at me?
No.
So I am not answering any further.
sk. maqdoom ali 6-Aug-12 3:30am    
no sir, i am not at all shout you , i just explained my requirement clearly thats it..... if i hurted u i am extreamly very very sorry.
OriginalGriff 6-Aug-12 3:42am    
Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalisation if you want to be taken seriously.

I think I understand what you're after. You want the record(s) previous to the current record?

If your query actually returns something, you could do this:

SQL
select (case when Deposit_Type =1 then 'RD' else 'FD' end) as Deposit_Type,
        ID,
        Scheme_Name,
        (case when Mode_Operation=1 then 'General' else 'SC' end)as Mode_Operation,
        Period_Type,
        Period_Value,
        Type_Interest,
        Interest_Rate,
        LockIn_Period,
        PNL_Interest,  
        Is_Active from [Scheme]
WHERE GETDATE() NOT BETWEEN Valid_From_Date AND Valid_To_Date


And if you want just the most current previous record:

SQL
select TOP 1 
(case when Deposit_Type =1 then 'RD' else 'FD' end) as Deposit_Type,
        ID,
        Scheme_Name,
        (case when Mode_Operation=1 then 'General' else 'SC' end)as Mode_Operation,
        Period_Type,
        Period_Value,
        Type_Interest,
        Interest_Rate,
        LockIn_Period,
        PNL_Interest,  
        Is_Active from [Scheme]
WHERE GETDATE() NOT BETWEEN Valid_From_Date AND Valid_To_Date
ORDER BY Valid_From_Date DESC 
 
Share this answer
 
v3
SQL
select (case when Deposit_Type =1 then 'RD' else 'FD' end) as Deposit_Type,
        ID,
        Scheme_Name,
        (case when Mode_Operation=1 then 'General' else 'SC' end)as Mode_Operation,
        Period_Type,
        Period_Value,
        Type_Interest,
        Interest_Rate,
        LockIn_Period,
        PNL_Interest,  
        Is_Active from Scheme WHERE GETDATE() < Valid_To_Date


You want to fetch all records irrespective of validstartdate but the only condition is it should be valid as of current date
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900