I have written a simple explore to see last split date & last split ratio for stocks in my database. For the stocks that have never had a split I get "Invalid DateTime" in the results. I know how to filter these out. However I want to know the reason for "Invalid DateTime". I want to know the problem with my code. Below you'll find the code and an screenshot.
Most probable reason is for those symbols you do NOT have ANY split date set, so GetFnDate("LastSplitDate") simply returns 0 (which is invalid value for datetime).
Tomasz, is there a technical reason that only "LastSplitDate" returns 0 for empty split date and not DividendPayDate, ExDividendDate and DelistingDate if they have empty values. Please see below.
Glad to see that it is not an inconsistency in design. As for your work around suggestion, I don't see how I can have an other_value_you_wish that represent null or empty value for a DateTime type field that does produce "Invadlid DateTime". The only option that I see is put bogus DateTime value in there.
Thanks @fxshrat, Clever. It makes sense. If we don't have a stock split, then
LastSplitDate retruns zero. Then in addtocolumn we try to format zero datetime and it outputs a string "invalid datetime". So replace that string with null we end up with the solution.
I already gave you the solution in post #6 (yes, any_other_value_you_wish can be NULL and if you use Null you will get "empty" cell). If you just read it carefully you would know by then:
It is worth noting too that doing StrFind() for "Invalid" is bad idea because text may get localised versions on non-English installations of Windows and code relying on English text would stop working.
I always wonder why don't people read my responses. My 2-3 sentences usually have more substance than paragraphs of texts of other people. So, do yourself a favor and pay attention.
(Maybe I'm missing some essential info or I misunderstood what value in your line referred to)... GetFnData("LastSplitDate") does not return 0 on my end but negative (when LastSplitDate entry is not set in Information window).
would still return "Invalid Datetime" instead of empty cell (apparently being looked for).
Since there are datetimes that return negative value close to zero too that was reason I used StrFind.
Again maybe I am missing something essential and value was not referring to LastSplitDate directly.
(Waiting for a slap on my head )
Normally this field, if not set, has value of ZERO, as all fields initially get filled with zeros. However, if you are using 3rd party plugin, it is free to set the value of this field to any value. Plugin has total control and can do whatever it wants. If you are not using plugin and have non-zero value that is not valid date, then I don't know from where you got that value, but certainly not from AB.