By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,835 Members | 2,333 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,835 IT Pros & Developers. It's quick & easy.

Problem with to_date/to_char

P: n/a
Hi,
Can somebody tell me why this query don't work when I use to_date
Instead of to_char

By using to_char:

select
to_char(last_day(cast(current_date - interval '1 month' as date)),'DD.MM.YYYY')
;

Result: 31.08.2003

By using to_date:

select
to_date(last_day(cast(current_date - interval '1 month' as date)),'DD.MM.YYYY')
;

Result: 01.23.0037

What can I do that this query works correctly with to_date?

Thanxx

Schoeib

4Tek Gesellschaft für angewandte Informationstechnologien mbH
Schoeib Amin
Tel. +49 (0) 69 697688-132
Fax. +49 (0) 69 697688-111
http://www.4tek.de
Nov 11 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Fri, Sep 05, 2003 at 11:26:05AM +0200, Amin Schoeib wrote:
Hi,
Can somebody tell me why this query don't work when I use to_date
Instead of to_char

By using to_char:

select
to_char(last_day(cast(current_date - interval '1 month' as date)),'DD.MM.YYYY')
;

Result: 31.08.2003

By using to_date:

select
to_date(last_day(cast(current_date - interval '1 month' as date)),'DD.MM.YYYY')
;


to_date() do conversion from 'string' to 'data' .... see docs.

Karel

--
Karel Zak <za***@zf.jcu.cz>
http://home.zf.jcu.cz/~zakkr/

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 11 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.