comparing date problem [message #122138] |
Fri, 03 June 2005 04:49 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
charlotte may
Messages: 8 Registered: June 2005
|
Junior Member |
|
|
hi, help needed!
i dunno whether i ask this Qs under the correct section.
if not, pls forgive me.
i'm currently doing a project using vb.net.
my data type for the VALID_DATE is Date in oracle.
so now i want to retrieve all the data from oracle that the VALID_DATE is < today date.
so i use below statement in my select statement:-
VALID_DATE < TO_DATE (SYSDATE, 'dd/Mon/yyyy' )
is work (no error occur), but the datagrid does not display the record that the
VALID_DATE < today date.
NOTE:
the VALID_DATE that store in oracle database is as below:-
(format of the VALID_DATE in database: month / day / year )
VALID_DATE
5/19/2005
7/3/2005
6/21/2005
even i try this also cannot:-
VALID_DATE < TO_DATE (SYSDATE, 'dd/MM/yyyy' )
any help provider? it's urgent!
thanks a lot!
regards;
charlotte
|
|
|
|
Re: comparing date problem [message #122318 is a reply to message #122314] |
Sun, 05 June 2005 21:38 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
charlotte may
Messages: 8 Registered: June 2005
|
Junior Member |
|
|
thanks djmartin!
the data type for valid_date is Date in oracle database.
that's mean i comparing date field againts date field.
so i try to use valid_date < SYSDATE , BUT it still din't display the records i want (it runs, no error, just din't display the records i want.)!
may i know why?
thanks for the help!
it's urgent, hope hear from you soon. thanks!
regards;
charlotte
|
|
|
|
Re: comparing date problem [message #122321 is a reply to message #122318] |
Sun, 05 June 2005 22:09 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](/forum/images/custom_avatars/67467.jpg) |
djmartin
Messages: 10181 Registered: March 2005 Location: Surges Bay TAS Australia
|
Senior Member Account Moderator |
|
|
From 'charlotte' via mail:
Quote: | Dim SQL As String = "SELECT a.APP_BADGE_NO, a.APP_ID, a.APP_NAME, a.APP_CAT, b.STFNAM, c.STFEXTNO FROM ESC_APPLICANT a, ESC_REQUESTOR b, CONTACT c WHERE a.STFNO = b.STFNO and a.STFNO = c.STFNO AND (a.STATUS = 'APPROVE' or a.STATUS = 'RENEW') and a.APP_VDATE_TO < SYSDATE "
Dim Cmd As New OleDbCommand(SQL, Conn)
Conn.Open()
DtReader = Cmd.ExecuteReader()
MyDataGrid.DataSource = DtReader
MyDataGrid.DataBind()
Conn.Close()
i even try a.APP_VDTAE_TO < trunc (SYSDATE). it still the same, no records display!
|
What I need you to do is use one of the other Oracle tools to test your SQL. Do you have access to TOAD or SQL*Plus?
Use either of these to run the SQL that you have in your code.
By the way, have your signed on to the database when you try to run this code?
David
[Updated on: Sun, 05 June 2005 22:10] Report message to a moderator
|
|
|
Re: comparing date problem [message #122323 is a reply to message #122321] |
Sun, 05 June 2005 22:21 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
charlotte may
Messages: 8 Registered: June 2005
|
Junior Member |
|
|
thanks again!
i'm sorry that i 'm not familiar with oracle and i don't think that i have permission to use TOAD & SQL*plus(i think so).
may i know what do you mean by signed on?
do you mean connect to Oracle database?
yup, i hv!
i can store and retrive the data from oracle.
so, i also dunno wat is going wrong!
may i know does SYSDATE refer to today date?
Coz i wanna compare the APP_VDATE_TO < today date!
any other ideas?
thanks!
|
|
|
|
|
|
Re: comparing date problem [message #122330 is a reply to message #122326] |
Sun, 05 June 2005 23:18 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
charlotte may
Messages: 8 Registered: June 2005
|
Junior Member |
|
|
hi, tx!
i check already!
the STFNO and APP_VDATE_TO is not null.
and it contain 1 record that the APP_VDATE_TO is less than today date!
in MS Access, if the APP_VDATE_TO is null, then it wouldn't generate the datagrid!
it will display the error say that the db is null!
it only will display the record if the APP_VDATE_TO & OTHERS SELECTED fields is not null.
did my query have some problem?
may i know what do you mean by "NVL constructs to resolve your query". how to do it?
regards;
charlotte
|
|
|
Re: comparing date problem [message #122331 is a reply to message #122330] |
Sun, 05 June 2005 23:59 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](/forum/images/custom_avatars/67467.jpg) |
djmartin
Messages: 10181 Registered: March 2005 Location: Surges Bay TAS Australia
|
Senior Member Account Moderator |
|
|
I am afraid that I am missing something very obvious, but I can't see it.
Quote: | Dim SQL As String = "SELECT a.APP_BADGE_NO, a.APP_ID, a.APP_NAME, a.APP_CAT, b.STFNAM, c.STFEXTNO FROM ESC_APPLICANT a, ESC_REQUESTOR b, CONTACT c WHERE a.STFNO = b.STFNO and a.STFNO = c.STFNO AND (a.STATUS = 'APPROVE' or a.STATUS = 'RENEW') and a.APP_VDATE_TO < SYSDATE "
|
I can't see anything wrong in this SQL. You do have it on one line, right?
[Update:]This string is 251 characters. Is there a maximum length associated with strings? Can you define your string to be longer?
All I can suggest is that you start with a more basic SQL statment, like "SELECT a.APP_BADGE_NO, a.APP_ID, a.APP_NAME, a.APP_CAT FROM ESC_APPLICANT a"
and then add "WHERE (a.STATUS = 'APPROVE' or a.STATUS = 'RENEW')", then add "and a.APP_VDATE_TO < SYSDATE", etc.
David
[Updated on: Mon, 06 June 2005 00:00] Report message to a moderator
|
|
|
Re: comparing date problem [message #122335 is a reply to message #122330] |
Mon, 06 June 2005 00:19 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
charlotte may
Messages: 8 Registered: June 2005
|
Junior Member |
|
|
hi, david!
i get an help from the staff here n he seem solve my problem already!
now i wanna select all the records for January so how am i going to write the sql statement?
Select * from ESC_APPLICANT where (ISSUE_DATE is january)?
sorry for keep on trouble you!
regards;
charlotte
|
|
|
|
Re: comparing date problem [message #122339 is a reply to message #122338] |
Mon, 06 June 2005 00:32 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
charlotte may
Messages: 8 Registered: June 2005
|
Junior Member |
|
|
hi,i thinks that u'll find it ridiculous!
o mayb stupid!
i attempt to change the APP_VDATE_TO in the oracle database!
mean that before that is 8-Jun-2005, i try to change to 2-Jun-2005.
it change(mean that i can view the date is 2-Jun-2005 in that table)!
but my friend say that what he get is 8-Jun-2005!
then i try to delete that records and add new records with the APP_VDATE_TO less than today date.
then it work and display records!
sorry for trouble u!
may i know that whether we can straight away change the data in the oracle?
another request, pls help me to solve the latest question that i post!
really hv to give u a big clap and big thanks!
regards;
charlotte
|
|
|
|
|