Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL select statement problem

Status
Not open for further replies.

sudhakarpothu

Programmer
Jan 8, 2007
19
DE
Hello Friends,

I have a problem with retreiving data from my oracle database using sql select statement.
here I am using a user form in vb to get the data from a begining date to ending date, my database has different coloumns for Year, month and Day

Here the problem is, the earlier programmer created the tables such that they take date in year, month and day as separate columns.

when i try to retreive data its checking these columns as separate fields but not as date.

my sql select staterment is

select wölbung_vorn, wölbung_hinten, Year, Month, Day from rsv.twm60 where Year>='" & Byear & "' and Year <='" & Eyear & "' and Month>='" & Bmonth & "' and Month<='" & Emonth & "' and Day>='" & Bday & "' and Day<='" & Eday & "'"

what i am trying is to take the input ( in user form ) as

Byear=2005 and Eyear=2006 ie is year between 2005 and 2006
Bmonth=1 and Emonth= 12 ie is month between 1 and 12
Bday=1 and Eday=8 ie is day between 1 and 8

so i am expecting it to return me all values from 1-1-2005 to 8-12-2006 but thats not happening it is just giving values of 2005 january 1 to 8 and december 1 to 8
and values from 2006 january 1 to 8 and december 1 to 8.

Please help me, I am trying to solve this by nested select statement but not getting.

sorry for taking your valuable time

Thank you.

Sudhakar Pothu.
 
Why dont you use between. Select blah where dbdate between start_date and end_date.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top