Subject | Re: [firebird-support] date function |
---|---|
Author | Helen Borrie |
Post date | 2004-10-02T11:38:03Z |
At 04:51 PM 2/10/2004 +0700, you wrote:
insert into aTable (aDate)
values (CURRENT_DATE)
and
SELECT CURRENT_DATE FROM RDB$DATABASE
and so on.
set blah = CURRENT_DATE + 1
DELETE from aTable
where date between CURRENT_DATE - 30 and CURRENT_DATE - 15
Operating with months isn't so simple - work out what you want and use
either an expression or a UDF.
See also CURRENT_TIMESTAMP (to include time) and the predefined date
literals 'TODAY', 'TOMORROW', 'YESTERDAY' and 'NOW'. PDDLs have to be cast.
So, these are the same:
SELECT CURRENT_DATE + 1 FROM RDB$DATABASE
and
SELECT CAST('TOMORROW' AS DATE) FROM RDB$DATABASE
./heLen
>Hi all,CURRENT_DATE
>
>I used to be an IBM DB2 user, for some good reasons I decide to move to
>Firebird. I'm new to Firebird, and having intensive study upon it
>currently. I
>have some problems around date/time management.
>
>1. In DB2, to get current date, simply use this query:
> values current date
> How to do this in Firebird?
insert into aTable (aDate)
values (CURRENT_DATE)
and
SELECT CURRENT_DATE FROM RDB$DATABASE
and so on.
>2. In DB2, to do addition/subtraction on date, simply use:UPDATE aTable
> values current date + 1 days
> or
> values current date - 1 months
> This operation is also accepted in delete, update, and insert query.
> How to do this in Firebird?
set blah = CURRENT_DATE + 1
DELETE from aTable
where date between CURRENT_DATE - 30 and CURRENT_DATE - 15
Operating with months isn't so simple - work out what you want and use
either an expression or a UDF.
>3. In DB2, to include current date info in a select query, simply use:SELECT CURRENT_DATE, FIELD_NAME FROM ATABLE
> select current date, field_name from table_name
> How to do this in Firebird?
See also CURRENT_TIMESTAMP (to include time) and the predefined date
literals 'TODAY', 'TOMORROW', 'YESTERDAY' and 'NOW'. PDDLs have to be cast.
So, these are the same:
SELECT CURRENT_DATE + 1 FROM RDB$DATABASE
and
SELECT CAST('TOMORROW' AS DATE) FROM RDB$DATABASE
./heLen