From SQL Server , I need to be able to pull some information from an Oracle database based on a date column.
SET @foo = 'SELECT * from OPENQUERY(' + @LinkedServer +
', ''SELECT *
FROM Table1
WHERE date_revised > '''''+@myDate+'''''')'
Don’t mind if the numbers of ' is off… I cut things out to make this shorter. I have tried using convert() on the SQL Server side, but I cannot seem to find a format that Oracle accepts, so it keeps throwing errors.
At a minimum, I require date, hours, and minutes. When testing values in SQL Developer (Oracle) to figure out acceptable formats, I keep running into this behavior:
select to_date('2010-11-15 12:21:00', 'yyyy/mm/dd hh:mi:ssam') from dual
15-NOV-10
Clearly, I specify I want time, but it just doesn’t agree with me. I’ve been stuck on this issue way too long.
In short, how do I format a SQL Server datetime into a format that Oracle’s to_date function will accept, and how do I make that function properly show date and time?
I came up with my own solution since Oracle was being uncooperative with me. I basically take the
DATEPARTSof everything and construct my own date-string in the same format in oracle. Thanks for your input all. When I get more time, I will try to get this working as it should. This bandaid will do for now.