Subject | Re: Formating date to yyyymmdd |
---|---|
Author | mbanaouas |
Post date | 2009-06-12T13:01:13Z |
--- In firebird-support@yahoogroups.com, "kokok_kokok" <kokok_kokok@...> wrote:
extract(year from cast('today' as date))
|| substring(cast(cast((100 + extract(month from cast('today' as date))) as integer) as varchar(100)) from 2 for 2)
|| substring(cast(cast((100 + extract(day from cast('today' as date))) as integer) as varchar(100)) from 2 for 2)
from rdb$database
>select
> Using Firebird 2.0, how can I format a date to yyyymmdd?
>
> For example Jan 15 2009 -> 20090115
>
> My first approach has been using EXTRACT(YEAR FROM BirthDate) || EXTRACT(MONTH FROM BirthDate) || EXTRACT(DAY FROM BirthDate)
> but it does not work for me because I need to lead zeros and I cannot find how do it. Maybe there is a direct function.
>
> Thanks
>
extract(year from cast('today' as date))
|| substring(cast(cast((100 + extract(month from cast('today' as date))) as integer) as varchar(100)) from 2 for 2)
|| substring(cast(cast((100 + extract(day from cast('today' as date))) as integer) as varchar(100)) from 2 for 2)
from rdb$database