Steve Dyke wrote:
Steve Luke wrote:I can think of 3 options:
1) Figure out when the null happens, and try to prevent it from happening by modifying your SQL. I am not SQL expert so I don't know how to do that (maybe build a case for when there is no ftdate? )
I would go with option 1 if I had a choice.
I don't see how I can use option 1 since the field does have a date even though it is wrong(10/14/0290)
My bad, I thought you were getting nulls because the data being retrieved did not exist. For example isn't there a 'Where x is Not Null' type of statement? Maybe just for certain DBs or statement types... dunno, like I said, I am not an expert. Couldn't that be used on a value being returned as a calculation based on some other field. Examples:
Or
Like I said, I don't know if either would work, I know just enough SQL to break things.
If it can't be fixed in SQL then you have to do something else. Where does the wrong date come from? What is the application you are working on? If your application is the data - entry application then
you should check the data in the
Java layer to make sure, by the time it gets to the DB, it is correct. If your application is just the data - receiver and the broken date is in the database then your application should dutifully report the problem and move on (without crashing - so using 2 or 3).
* The in-code problem is caused because the dayofweek SQL function returns null - cascading to null being returned as the ftdate column. Your real problem comes from the bad date in the database. The solution to the real problem is to assign the correct date to the broken one in the database and fix your data entry method so as to prevent this type of thing in the future.