Subject | Re: [ib-support] Subtrac a day from a date: how? |
---|---|
Author | Helen Borrie |
Post date | 2003-01-07T22:54:33Z |
At 09:26 PM 7/01/2003 +0000, Marco Menardi wrote:
from an SQL statement is:
select field1, field2, date1 - 1 as calcdate, ....
or, more likely, you are using mydate as replaceable parameter:
select field1, field1, ...
where date1 = :mydate - 1
....
....
MyQuery.ParamByName('mydate').AsDate = StrToDate('2003-01-07');
---provided, of course, that your client environment can recognise this
string as a valid date format. The problem of client date formats is a
Delphi one of long standing. We luckless folk outside the US often have to
decode inputs to date-only fields because many Delphi routines won't
recognise date-only dates unless they are in mm/dd/yy or
mm/dd/ccyy. (According to the doc, the routines should obey the Windows
locale but, alas, it doesn't always work like that.)
In Delphi, it's always better to pass an actual Date datum to the parameter
than to rely on Delphi's ability to cast a date string correctly...
heLen
>Hi, how can I subtract a day from a date? I mean, I have the dateDelphi aside (off-topic here) and assuming Dialect 3, the way to get it
>(yyyy-mm-dd format):
>2003-01-07
>and I want to subtract one day so I will have:
>2003-01-07 <-- do you mean 2003-01-06?
>(of course, if 2003-02-01 i want 2003-01-31...)
>I've tried a Delphy like:
>mydate = start_date_field - 1;
>but it raises an error...
from an SQL statement is:
select field1, field2, date1 - 1 as calcdate, ....
or, more likely, you are using mydate as replaceable parameter:
select field1, field1, ...
where date1 = :mydate - 1
....
....
MyQuery.ParamByName('mydate').AsDate = StrToDate('2003-01-07');
---provided, of course, that your client environment can recognise this
string as a valid date format. The problem of client date formats is a
Delphi one of long standing. We luckless folk outside the US often have to
decode inputs to date-only fields because many Delphi routines won't
recognise date-only dates unless they are in mm/dd/yy or
mm/dd/ccyy. (According to the doc, the routines should obey the Windows
locale but, alas, it doesn't always work like that.)
In Delphi, it's always better to pass an actual Date datum to the parameter
than to rely on Delphi's ability to cast a date string correctly...
heLen