I am building an in-line SQL query (no need to comment about this I know its not the best method but its how the company does things!) and I need to compare an Oracle DATE column with C# DateTime.Now. What conversions do I need to put around the DateTime.Now and the column in order to get this comparison to work? (I want to compare the whole DateTime object not just the Date part)
Share
You can use the Oracle TO_DATE function.
For the c# date (see custom date and time strings):
If you want to add hours/minutes/seconds, you can modify accordingly.
edit – Actually since you mentioned the whole thing and not just the date, I’ll add it. 🙂
At home so I can’t run it, but that should work.
To build a string with the where clause, you’d do this:
If you wanted to use a specific date rather then DateTime.Now, just put the variable holding it there instead.