Home » SQL & PL/SQL » SQL & PL/SQL » Date conversion
Date conversion [message #19183] Mon, 04 March 2002 10:45 Go to next message
Parag dave
Messages: 8
Registered: February 2002
Junior Member
Hi,
I have date prompt like (01-JAN-2001)
now I have to compare this date's month with my table
field' date's month which is the same format as my prompt. I want to compare the month like 01 = 01
I am going to use it in my decode statement. How do I
construct my select statement? I tried many ways and
got nothing but errors. Any Idea will be appreciated
Thanks.
Re: Date conversion [message #19184 is a reply to message #19183] Mon, 04 March 2002 11:09 Go to previous message
Jon
Messages: 483
Registered: May 2001
Senior Member
16:07:01 ==> drop table table1;

Table dropped.

16:07:02 ==> create table table1 (date1 date, val1 varchar2(1));

Table created.

16:07:03 ==> insert into table1 values (to_date('01-JAN-2002','DD-MON-YYYY'), 'X');

1 row created.

16:07:03 ==> insert into table1 values (to_date('02-JAN-2002','DD-MON-YYYY'), 'L');

1 row created.

16:07:03 ==> insert into table1 values (to_date('02-JAN-2002','DD-MON-YYYY'), 'R');

1 row created.

16:07:03 ==> insert into table1 values (to_date('01-JAN-2002','DD-MON-YYYY'), 'E');

1 row created.

16:07:03 ==> insert into table1 values (to_date('01-JAN-2002','DD-MON-YYYY'), 'M');

1 row created.

16:07:03 ==> SELECT *
16:07:03 2 FROM table1
16:07:03 3 WHERE TRUNC(date1) = TRUNC(TO_DATE('&SELECT_DATE','DD-MON-YYYY'));
Enter value for select_date: 02-JAN-2002
old 3: WHERE TRUNC(date1) = TRUNC(TO_DATE('&SELECT_DATE','DD-MON-YYYY'))
new 3: WHERE TRUNC(date1) = TRUNC(TO_DATE('02-JAN-2002','DD-MON-YYYY'))

DATE1 V
---------- -
01/02/2002 L
01/02/2002 R

16:07:16 ==>
Previous Topic: Oracle 8i truncate
Next Topic: order by variable
Goto Forum:
  


Current Time: Fri Apr 26 09:38:51 CDT 2024