C# LINQ Oracle date Functions

Posted by user1079925 on Stack Overflow See other posts from Stack Overflow or by user1079925
Published on 2012-11-13T10:57:47Z Indexed on 2012/11/13 10:59 UTC
Read the original article Hit count: 719

Filed under:
|
|
|

I am trying to generate a sql statement to be used in Oracle11g, using linq.

The problem arises when using dates:

The SQL generated by linq gives

SELECT *
FROM <table>
WHERE start_date > '24/11/2012 00:00:00' and end_date < '28/11/2012 00:00:00'

This causes an oracle error: ORA-01830 - date format picture ends before converting entire input string

Adding TO_DATE to the query fixes the ORA-01830, as it is converting the string to a oracle date whilst now knowing the date format.

SELECT *
FROM <table>
WHERE start_date > TO_DATE('24/11/2012 00:00:00','DD/MM/YYYY HH24:MI:SS') and end_date < TO_DATE('28/11/2012 00:00:00','DD/MM/YYYY HH24:MI:SS')

So, is there a way to add TO_DATE to LINQ (for oracle)? If not, please tell me how to work around this issue.

Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ