C # How to parse a date string in an arbitrary given Oracle date format?

How do I parse a date string in an arbitrary given Oracle date format in C #?

So ... the oracle format string is slightly different from the C # datetime format string, so I cannot use that formatted string as an argument to parse. I'm using Devart / CoreLab, but their OracleDate.Parse seems really strange and doesn't work for me. How can I parse it correctly? Do I have to call the query in the db with TO_DATE / TO_CHAR to get the transformation? Or that I should map each oracle format string element to a c # format string element?

edit: And the Oracle and C # format string is different, like MON instead of MMM ...

edit2: clarification: Basically, I would have strings that are oracle-date in a string, eg. "08-OCT-85" and I can also get the oracle format pattern following the date string like "DD-MON-YY", "DD-MON-RR", "YYYY / RM / DD" "... etc.

I would like to parse them correctly in C # DateTime so that I can set them to Parameter (which C # DateTime expects) and the problem is in this oracle-date-format pattern does not match the C # DateTime-parse-format-pattern.

I suspect there might be some function out there somewhere that can do something like DateTime dt = ParseDatestringWithSpecifiedOracleDatePatternIntoCSharpDateTime ("08-OCT-85", "DD-MON-YY), right? But I still can't find it :(

+1


source to share


2 answers


DateTime.TryParseExact

allows you to pass a format string to determine the format exactly (or an array of formats to try one at a time).



+2


source


Could you use DateTime.TryParseExact()

with the specified format string?



+1


source







All Articles