<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><span></span></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><span></span></div><div><div dir="ltr">
<p style="margin-bottom:0in;line-height:100%">I use the following
function to read a date from a Libre Office dbase file. The field is
stored as</p>
<p style="margin-bottom:0in;line-height:100%">a string, ie
'04/08/2016'.
</p>
<p style="margin-bottom:0in;line-height:100%"><br>
</p>
<p style="margin-bottom:0in;line-height:100%">function
db_date(const dog_base:tdbf;const t_field:string):tdatetime;</p>
<p style="margin-bottom:0in;line-height:100%">var
test_date:tdatetime;</p>
<p style="margin-bottom:0in;line-height:100%">test_bool:boolean;</p>
<p style="margin-bottom:0in;line-height:100%">test_string:string;</p>
<p style="margin-bottom:0in;line-height:100%">begin {starts
function db_date(const dog_base:tdbf;const
t_field:string):tdatetime;}</p>
<p style="margin-bottom:0in;line-height:100%">
test_bool:=dog_base.FieldByName(t_field).Value<>null;</p>
<p style="margin-bottom:0in;line-height:100%"> if test_bool
then test_date:=dog_base.FieldByName(t_field).AsDateTime</p>
<p style="margin-bottom:0in;line-height:100%"> else
test_date:=now;</p>
<p style="margin-bottom:0in;line-height:100%">
result:=test_date;</p>
<p style="margin-bottom:0in;line-height:100%">end; {ends function
db_date(const dog_base:tdbf;const t_field:string):tdatetime;}</p>
<p style="margin-bottom:0in;line-height:100%">
</p>
<p style="margin-bottom:0in;line-height:100%">I am running lazarus
1.6, on both Windows 8 and Linux Mint 17. The above function works
fine on the Windows 8 box, but on the Linux Mint box, I get the
following error: “04/08/2016” is not a valid date format. Why
does it work on Windows but not Linux? How can I rewrite it to work
on both?
</p>
</div>
</div></div></body></html>