473,426 Members | 1,567 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,426 software developers and data experts.

Problem with to_date/to_char

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
1 5658
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: KULJEET | last post by:
hi i have a table c_table with two columns no, date it contains records no n_date 1 10-AUG-03 2 21-AUG-03
3
by: ofer_c33 | last post by:
when i put record into table in this format insert into test(boat_id,strartDate) values(2,to_date('2004-01-02 16:00:00','YYYY-MM-DD HH24:MI:SS')); it is lood ok but when i try to fet the record...
3
by: Wei Wang | last post by:
I get compile error for this code: for i in 1..arg_count-1 LOOP RAISE NOTICE quote_literal(to_char(i, ''9'')); END LOOP; where arg_count = 3. I tried RAISE NOTICE to_char(i, ''9''); as...
1
by: TANUJ | last post by:
i m working on oracle forms 6i n enable to fetch the record in time format. on form, field type is date with format mask hh24:mi but when i fetch it using to_char function nd trans it into...
14
by: peteh | last post by:
Hi All; We have many production jobs that "load from cursor" to a UDB/AIX 8.2 (with dpf) data warehouse from source tables residing Oracle 9i. Since Oracle dates are (roughly) equivalent to DB2...
0
by: Lenny | last post by:
Hi. I've a problem with an update from the sqldatasource the table cannot be modified because it is from a third party sw table fields are: codice, fcli_inizio, fcli_fine. keys are codice and...
0
by: woodsc | last post by:
Hi all, I am trying to optimize the queries in my application. Is there a performance difference between (to_char(myDate,format) < myString) and (myDate < to_date(myString, format)). ex. ...
2
by: moyoal | last post by:
Dear All, Help me! From application i am sending date parameter to report which is in 'DD-MON-RRRR' format... In a table i have a column TRX_DATE in want to compare this column with Form...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.