Home > Archive > Oracle Server > July 2005 > How To Compare Date with Just the Day of Month









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How To Compare Date with Just the Day of Month
Rhugga

2005-07-28, 9:23 am


I have the following date inserted into a DATE field: 07-26-2005
21:00:00

I have some code where I want to see if this date is equal to
07-26-2005, regardless of the time of day.

This is not working form me:
WHERE bcv_start = to_date('$bcv_sdate[$j]', 'MM-DD-YYYY')

(The value of $bcv_date is correct, I have check that several times)
Thx,
CC

Wally

2005-07-28, 9:23 am

try

WHERE to_date(bcv_start,'M
M-DD-YYYY') = to_date('$bcv_sdate[$j]',
'MM-DD-YYYY')

HTH
Wally

IANAL_VISTA

2005-07-28, 9:23 am

"Rhugga" <chuck.carson@gmail.com> wrote in
news:1122557420.795340.5200@f14g2000cwb.googlegroups.com:

>
> I have the following date inserted into a DATE field: 07-26-2005
> 21:00:00
>
> I have some code where I want to see if this date is equal to
> 07-26-2005, regardless of the time of day.
>
> This is not working form me:
> WHERE bcv_start = to_date('$bcv_sdate[$j]', 'MM-DD-YYYY')
>
> (The value of $bcv_date is correct, I have check that several times)
> Thx,
> CC
>
>


You are using the wrong end of the shovel to dig a hole.

Is "$bcv_sdate[$j]" a string or a date datatype?

This appears to be SQL embedded in PERL code.

WHERE TRUNC(BCV_START) = $bcv_sdate[$j]?
Jim Kennedy

2005-07-28, 9:23 am


"Rhugga" <chuck.carson@gmail.com> wrote in message
news:1122557420.795340.5200@f14g2000cwb.googlegroups.com...
>
> I have the following date inserted into a DATE field: 07-26-2005
> 21:00:00
>
> I have some code where I want to see if this date is equal to
> 07-26-2005, regardless of the time of day.
>
> This is not working form me:
> WHERE bcv_start = to_date('$bcv_sdate[$j]', 'MM-DD-YYYY')
>
> (The value of $bcv_date is correct, I have check that several times)
> Thx,
> CC
>


use trunc(bcv_start) trunc on a date removes the fraction of a day and
makes it midnight of that day which to_date('$bcv_sdate[$j]', 'MM-DD-YYYY')
is. If it is slow then use a function based index on that field.
Jim


Wally

2005-07-28, 9:23 am

sorry, my bad. ignore my previos post.

try

WHERE to_char(bcv_start,'M
M-DD-YYYY') = $bcv_sdate[$j]

that way you compare only the date part of the bcv_start field. By make
sure that the value of the vairable = $bcv_sdate[$j] is in the same
format MM-DD-YYYY.

Wally

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com