Click here to Skip to main content
15,921,643 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi In my table i have one field 'FLD_DATE' . I want to fetch the records based on 'FLD_DATE' field.
i want to take the records based on date intervel.
that is,
if i give 01/jan/2013 as my date filed then i hvae to take the records which have date starting from 01/jan/2013.
How can i do this??
Posted
Updated 10-Jun-13 20:15pm
v4

1 solution

Hello Gayathri,

Assuming FLD_DATE is of type DATE you can write a simple select query to retrieve the data. The below example shows how you can write such query in oracle.
SQL
SELECT * FROM YOUR_TABLE WHERE FLD_DATE >= TO_DATE('01/JAN/2013', 'DD/MON/YYYY')

If you are calling this query from .NET front-end then you will be using DBCommand in which case the string value(User Input) will be first converted to a Date type variable and then that converted value will be passed to the DBCommand as a parameter. Below snippet shows how it can be done in C# using Oracle Data Provider for .NET[^].
C#
OracleConnection con;
OracleCommand cmd;
OracleParameter prm;
OracleDataReader reader;

con = new OracleConnection(); 
con.ConnectionString = "User Id=scott;Password=tiger;Data Source=oracle"; 
con.Open(); 
cmd = new OracleCommand("SELECT * FROM TABLE_FOO WHERE fld_date >= :filtDate");
prm = new OracleParameter("filtDate", OracleDbType.Varchar2); 
prm.Direction = ParameterDirection.Input; 
prm.value = dtFilter;
cmd.Parameters.Add(prm); 
reader = cmd.ExecuteReader();
// Code for reading the records
reader.Dispose();
cmd.Dispose();

Regards,
 
Share this answer
 
Comments
Am Gayathri 11-Jun-13 2:47am    
Thanks

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