Click here to Skip to main content
15,888,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a column create_date( date) in my table. It is having one year data.

I want to fetch those data, which are last 6 month data from the current date..

Example - today's date is - 3rd October, I want all the date from 3rd April.

Thanks in advance.

What I have tried:

I am still trying to find the exact solution..
Posted
Updated 3-Oct-16 0:27am
v3

Try:
SQL
SELECT * FROM MyTable WHERE create_date > DATEADD(mm, -6, GETDATE())
 
Share this answer
 
Comments
Bittu14 3-Oct-16 4:13am    
Dateadd function is not working in oracle SQL. It is a function of SQL server.

I have tried it before. Its seems that "DATEADD ": invalid identifier.
OriginalGriff 3-Oct-16 4:23am    
If you want Oracle solutions, **then tell us it's Oracle** !
Read the documents: https://docs.oracle.com/cd/E51711_01/DR/Dateadd.html
And try that:
DateAdd(Date(), "1", , -6)
Bittu14 3-Oct-16 5:51am    
Still it is not working.. :(
Hello

For MS SQL Server You can use:
C#
where datetime_column >= Dateadd(Month, Datediff(Month, 0, DATEADD(m, -6, current_timestamp)), 0)


hope it works
best regards
 
Share this answer
 
Comments
Bittu14 3-Oct-16 5:44am    
I want it in oracle SQL.
I got my Answer.

The answer is -

Select create_date from test_date where create_date > sysdate-180;

thanks for everyone's help... :)
 
Share this answer
 

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