2

How to cast '2015-11-13 00:00:00' (text or timestamp) to '2015-11-13'(date) in Enterprisedb (EDB) ?

With 4 queries below:

1/ SELECT '2015-11-13 00:00:00'::date ; --> result: "2015-11-13" 
2/ SELECT date ( '2015-11-13 00:00:00' ) ;
3/ SELECT cast ( '2015-11-13 00:00:00' as date) ;
4/ SELECT to_char('2015-11-13 00:00:00'::timestamp, 'yyyy-mm-dd'::text);

In EDB 9.3 , just one query no.4 can cast. And PG 9.3 , all queries can do.

Are there still any ways to cast date in EDB ?

EDIT: With EDB :

 1/ SELECT '2015-11-13 00:00:00'::date ; --> result: "2015-11-13 00:00:00" 
 2/ SELECT date ( '2015-11-13 00:00:00' ) ; --> result: "2015-11-13 00:00:00" 
 3/ SELECT cast ( '2015-11-13 00:00:00' as date) ; --> result: "2015-11-13 00:00:00" 
 4/ SELECT to_char('2015-11-13 00:00:00'::timestamp, 'yyyy-mm-dd'::text); --> result: "2015-11-13" 
asked Nov 13, 2015 at 10:13
3
  • All of them should work in EnterpriseDB. What exactly is the error you get? Commented Nov 13, 2015 at 10:53
  • I will clarify my post . With Enterpriseb, only the query number 4 (select to_char....) can work as I wish. I do not know why query number 1 can not cast. I think , EDB do not have "date" data type. Commented Nov 13, 2015 at 11:06
  • 5
    EDB tries to be Oracle compatible, and in Oracle a DATE contains a time part, maybe that's the reason. If that is, you need to check if you can disable the Oracle compatibility. Commented Nov 13, 2015 at 11:09

1 Answer 1

1

Check the server's redwood date setting:

show edb_redwood_date

If set to 'on' it includes times as part of dates, if set to 'off' it does not.

Change the setting with:

alter system set edb_redwood_date=off;
select pg_reload_conf();

See: enterpriseDB.com Docs - edb_redwood_date

answered Dec 12, 2022 at 18:13

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.