select time or date value from a date field?
Posted in 2008
Summary
Victor asked how to pull just the date part and just the time part out of a DATETIME column in Informix, hoping for something like a FORMAT() function. One reply suggested TO_DATE, but his attempt (to_date(create_dt,"yyyy-mm-dd") / "hh:mm") didn't work. Art Kagel gave the working answer: use EXTEND, e.g. SELECT extend(create_dt, YEAR TO DAY) AS create_date, extend(create_dt, HOUR TO MINUTE) AS create_time FROM table. No further follow-up is recorded.
Auto-generated by DrWatson from the posts below — may be imperfect; read the full thread.
↪ replying to vchu via DBMonster.com
vchu via DBMonster.com wrote:
> do we have something like
>
> select format(create_dt, "yyyy-mm-dd"),
> format(create_dt,"hh:mm") from anInformaixTable;
>
> Thanks
> Victor
>
Yes. TO_DATE
↪ replying to KStahl
sorry, I am new in this area.
I tried:
select to_date(create_dt, "yyyy-mm-dd"),
to_date(create_dt,"hh:mm") from anInformaixTable;
but it is not ok
KStahl wrote:
>> do we have something like
>>
>[quoted text clipped - 3 lines]
>> Thanks
>> Victor
>
>Yes. TO_DATE
--
Message posted via DBMonster.com
http://www.dbmonster.com/Uwe/Forums.aspx/informix/200803/1
↪ replying to KStahl
sorry, I am new in this area.
I tried:
select to_date(create_dt, "yyyy-mm-dd"),
to_date(create_dt,"hh:mm") from anInformaixTable;
but it is not ok
KStahl wrote:
>> do we have something like
>>
>[quoted text clipped - 3 lines]
>> Thanks
>> Victor
>
>Yes. TO_DATE
--
Message posted via DBMonster.com
http://www.dbmonster.com/Uwe/Forums.aspx/informix/200803/1
↪ replying to vchu via DBMonster.com
vchu via DBMonster.com wrote:
> do we have something like
>
> select format(create_dt, "yyyy-mm-dd"),
> format(create_dt,"hh:mm") from anInformaixTable;
>
> Thanks
> Victor
>
>
SELECT extend( create_dt, YEAR TO DAY) as Create_Date,
extend( create_dt, HOUR TO MINUTE) as Create_Time
FROM anInformixTable ...;
Assuming of course that the table has a column named create_dt...
Art S. Kagel
Oninit
===========================================================================================
Please access the attached hyperlink for an important electronic communications disclaimer:
http://www.oninit.com/home/disclaimer.php
===========================================================================================