Reputation: 637
I am building report in data warehouse which relay on comparing daily checks and payments for one of the restaurants. I need to be able to filter data on date field however it needs to be compared with string that looks like US date format but is string so
Select a.* from
xx a, xy b
where
a.payment_date = b.check_date
Format of a.payment_date is DD-MON-YY(date) and format of b.check_date is MM/DD/YYYY however it is a string. Any pointers to most efficient ways of solving this problem greatly appreciated.
Upvotes: 0
Views: 325
Reputation: 75
i think this may work fr you
Select a.* from xx a, xy b where convert(datetime,a.payment_date) = convert(datetime,b.check_date)
Upvotes: 0
Reputation: 6466
Convert both String dates into real dates (http://www.techonthenet.com/oracle/functions/to_date.php) so you can compare them date-wise.
Upvotes: 1
Reputation: 91299
Convert check_date
from string
to date
using TO_DATE()
:
SELECT a.*
FROM xx a, xy b
WHERE a.payment_date = TO_DATE(b.check_date, 'mm/dd/yyyy')
Or you can do the other way around, using TO_CHAR()
.
Upvotes: 2