473,794 Members | 2,983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bug in function to_char() !!

Hi, i am using PostgreSQL 7.3.2

there's a bug for the date '2005-03-27' !!!!!!!!!!!!!!! !!!!!!!!!!!!

SELECT to_char('2005-03-27'::date,'DD/MM/YYYY');
to_char
------------
26/03/2005
(1 row)

I get the date 26/03/2005 instead of 27/03/2005 !!!

For other dates the function works well !!
Nov 23 '05 #1
14 3528
Najib Abi Fadel wrote:
Hi, i am using PostgreSQL 7.3.2

there's a bug for the date '2005-03-27' !!!!!!!!!!!!!!! !!!!!!!!!!!!
I think you should replace or clean your keyboard. At least one key
seems to be sticky.
SELECT to_char('2005-03-27'::date,'DD/MM/YYYY');
to_char
------------
26/03/2005
(1 row)


No problem with 7.2.1 and 7.4.1. (don't have a 7.3.2 around).
Both work correctly:

dirk=> SELECT to_char('2005-03-27'::date,'DD/MM/YYYY');
to_char
------------
27/03/2005
(1 row)

--
D i r k F "o r s t e r l i n g
r@zorbla.de http://r.zorbla.de/
-------------
"A radioactive cat has eighteen half-lives."

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postg resql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #2
On Thu, Jul 01, 2004 at 09:47:38AM +0200, Najib Abi Fadel wrote:
Hi, i am using PostgreSQL 7.3.2

there's a bug for the date '2005-03-27' !!!!!!!!!!!!!!! !!!!!!!!!!!!

SELECT to_char('2005-03-27'::date,'DD/MM/YYYY');
to_char
------------
26/03/2005
(1 row)

I get the date 26/03/2005 instead of 27/03/2005 !!!


7.5devel:

# SELECT to_char('2005-03-27'::date,'DD/MM/YYYY');
to_char
------------
27/03/2005
The date looks like some date when is daylight saving time change,
maybe it's something already knows and fixed.

Can you check results of:

# SELECT '2005-03-27'::timestamp;
timestamp
---------------------
2005-03-27 00:00:00

# SHOW TIMEZONE;
TimeZone
---------------
Europe/Prague
Karel

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

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #3
On Thu, Jul 01, 2004 at 09:53:34AM +0200,
Dirk Försterling <r@zorbla.de> wrote
a message of 33 lines which said:
No problem with 7.2.1 and 7.4.1. (don't have a 7.3.2 around).


7.3.4 seems OK so I assume the guy with the exclamation marks did not
type what he sent:

% psql template1
Welcome to psql 7.3.4, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit

template1=> SELECT to_char('2005-03-27'::date,'DD/MM/YYYY');
to_char
------------
27/03/2005
(1 row)
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #4
[cpn@s00 work]$ rpm -q postgresql
postgresql-7.3.4-11

Fedora Core 1

KakaoStats=# SELECT
to_char('2005-03-27'::date,'DD/MM/YYYY');
to_char
------------
27/03/2005
(1 row)
--- Dirk_Försterlin g <r@zorbla.de> escreveu: > Najib
Abi Fadel wrote:
Hi, i am using PostgreSQL 7.3.2

there's a bug for the date '2005-03-27'

!!!!!!!!!!!!!!! !!!!!!!!!!!!

I think you should replace or clean your keyboard.
At least one key
seems to be sticky.
SELECT to_char('2005-03-27'::date,'DD/MM/YYYY');
to_char
------------
26/03/2005
(1 row)


No problem with 7.2.1 and 7.4.1. (don't have a 7.3.2
around).
Both work correctly:

dirk=> SELECT
to_char('2005-03-27'::date,'DD/MM/YYYY');
to_char
------------
27/03/2005
(1 row)

--
D i r k F "o r s t e r l i n g
r@zorbla.de http://r.zorbla.de/
-------------
"A radioactive cat has eighteen
half-lives."

---------------------------(end of
broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please
send an appropriate
subscribe-nomail command to
ma*******@postg resql.org so that your
message can get through to the mailing list
cleanly


_______________ _______________ _______________ _______________ __________

Yahoo! Mail - agora com 100MB de espaço, anti-spam e antivírus grátis!
http://br.info.mail.yahoo.com/

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #5
I exactly typed what i sent.
Anyone with Postgresql 7.3.2 PLEASE try it and tell me what happens.

SELECT to_char('2005-03-27'::date,'DD/MM/YYYY');
7.3.4 seems OK so I assume the guy with the exclamation marks did not
type what he sent:


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #6
Najib Abi Fadel wrote:
I exactly typed what i sent.
Anyone with Postgresql 7.3.2 PLEASE try it and tell me what happens.

SELECT to_char('2005-03-27'::date,'DD/MM/YYYY');

template1=# select version();
version
------------------------------------------------------------------------
PostgreSQL 7.3.2 on i386-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2.3
(1 row)

template1=# SELECT to_char('2005-03-27'::date,'DD/MM/YYYY');
to_char
------------
27/03/2005
(1 row)
Stefan

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #7
On Thu, 2004-07-01 at 14:48, Stefan Kaltenbrunner wrote:
Najib Abi Fadel wrote:
I exactly typed what i sent.
Anyone with Postgresql 7.3.2 PLEASE try it and tell me what happens.

SELECT to_char('2005-03-27'::date,'DD/MM/YYYY');

template1=# select version();
version
------------------------------------------------------------------------
PostgreSQL 7.3.2 on i386-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2.3
(1 row)

template1=# SELECT to_char('2005-03-27'::date,'DD/MM/YYYY');
to_char
------------
27/03/2005
(1 row)


I had the same problem in php due to DST, but that I guess depends on
the underlaying (buggy?) libc.

using 2005-03-27 12:00 instead of just 2005-03-27 solved the problem for
me.
regards,
Robin
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #8
"Najib Abi Fadel" <na*******@usj. edu.lb> writes:
SELECT to_char('2005-03-27'::date,'DD/MM/YYYY');
to_char
------------
26/03/2005
(1 row)


What timezone setting are you using, and what kind of system is this on?
I suppose that day is a daylight-savings transition day for you, but no
one else is likely to reproduce the problem in a different zone ...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postg resql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #9
Najib Abi Fadel wrote:
Hi, i am using PostgreSQL 7.3.2
there's a bug for the date '2005-03-27' !!!!!!!!!!!!!!! !!!!!!!!!!!!
For other dates the function works well !!


I have 7.4.2 and it works well:

maciej@matylda: ~$ psql template1
Welcome to psql 7.4.2, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit

template1=# SELECT to_char('2005-03-27'::date,'DD/MM/YYYY');
to_char
------------
27/03/2005
(1 row)

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
18395
by: Praveen | last post by:
Hi All, I have some procedures which written in Oracle. Now the requirement has come to convert those procedures into db2. I used IBM provided MTK tool to convert the procedures. The tool has given the syntax for TO_DATE function. When i tried to execute in db2 command line prompt, it says an error... db2 => select ORA8.TO_DATE(ORA8.TO_CHAR(CURRENT TIMESTAMP , 'mm-dd-yyyy'), 'mm-d
12
9548
by: Newbie | last post by:
how can i call an oracle function to get data without using a select statement or stored procedures? given a project_no, i need to call the function: ops$sqltime.pa_new_job_no_fn which will return the next job_no thanks in advance.
3
2519
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 well.
0
1818
by: Ian E. Morgan | last post by:
After being frustrated with the inflexible output of intervals, I've written a pl/pgsql function to do what I want, and hopefully some other people might find it useful. Output is a string that matches the output format of an interval as closely as possible, but rather than counting days as a fixed 24-hours, it recalculates days based on the number of hours in the desired 'day'. For example, this is very useful for summing up work time...
1
16219
by: Hollywood_Jack | last post by:
Peeps, I'm getting an "ORA-00937: not a single group group function error" when I try and run the following query. Any help is appreciated: SELECT tbt.major_cov_cd||', '|| tbt.claim_id||', '|| tbt.accident_date||', '|| tbt.carrier_notified_date||', '|| tbt.accident_date||', '|| tbt.close_date||', '|| tbt.reopen_date||', '||
1
7634
by: rkohon | last post by:
Hello all, I am new to JavaScript and need some ideas, suggestions, or code snippets. I have a form which requires the end user to put in a date for required items. I need javascript function to run on this date supplied by end user and for it to populate another area of the form with the Fiscal Year that this will be needed in. Example: User populates form field with 25-SEPT-07 we need the the Quarter required to immediately poplate...
1
1801
by: holdingbe | last post by:
Hi friends, I need to round or truncate the time.. If 1:24 means i need 1 clock 1:32 means i need 2 clock ... suppose the time in 11:45 PM i need 12:00 am and the time in 11:45 am i need 12:00 pm.. the time should be 12 hours format i write a query in 24 hours SELECT (CASE WHEN SUBSTR(TO_CHAR(SYSDATE,'HH24:MI'),4,5) >=30 THEN SUBSTR(TO_CHAR(SYSDATE,'HH24:MI'),1,2)+1
0
9230
debasisdas
by: debasisdas | last post by:
This function takes 2 dates as parameter and returns the number of working days. You need to add the list of holidays. (I have added a few as sample) CREATE OR REPLACE FUNCTION BUSINESS_DAYS ( i_Date1 IN DATE, i_Date2 IN DATE ) RETURN NUMBER IS
1
3857
by: waraujobh | last post by:
The Oracle function TO_CHAT accept DATE datatype. In DB2, i know that exist the VARCHAR_FORMAT function (synonym TO_CHAR), but this function only accepts TIMESTAMP datatypes. How can i have the same result in DB2, like this SQL in Oracle: SELECT to_char(data_entrada,'YYYYMM') FROM t1 Obs: data_entrada is of datatype DATE. Thanks, Wellerson
0
10435
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9037
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5436
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.