pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: czezz <czezz@o2.pl>
To: pgsql-admin@postgresql.org
Subject: display to_timestamp in quotas or convert to char
Date: Tue, 05 May 2015 13:26:24 +0200
Message-ID: <657111c9.5817f52.5548a8e0.89d25@o2.pl> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-admin>

Hello,
This post might be unreadable in your mail client. If so try to copy it in to notepad as there is a long query statement.


I have following table in the DB.

Server2=# \d ss21_file
              Table "srx.ss21_file"
      Column       |          Type          | Modifiers
-------------------+------------------------+-----------
value             | character varying(30)  |
fileindex         | bigint                 |
filename          | character varying(80)  |
filetime          | character varying(100) |
filesizeinrecords | bigint                 |
filesizeinbytes   | bigint                 |
sourceid          | character varying(300) |
Indexes:
    "ss21_filetime" UNIQUE, btree (filetime)

When executing following query I get following error:

Server2=# SELECT value, fileIndex, fileName, fileTime, fileSizeInRecords, fileSizeInBytes, sourceID   FROM ss21_file WHERE filetime < to_timestamp('2015-05-04 22:13:14.000', 'YYYY/MM/DD-HH24:MI:SS.FF3');
ERROR:  operator does not exist: character varying < timestamp with time zone
LINE 1: ...ytes, sourceID   FROM ss21_file WHERE filetime < to_times...
                                                             ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

My assumption is that, it is because "filetime" column is "character varying" and in WHERE condition value there is converted to timestamp.
When I execute this same query but instead to_timestamp I use regular string eg. '2015-05-04 22:13:14.000' (NOTE: single quotas) it works quite good.
If this is correct, is there any way to force to_"timestamp" function to be convertrd in to "character varying" or display its value in single quotas ?

Server2=# SELECT value, fileIndex, fileName, fileTime, fileSizeInRecords, fileSizeInBytes, sourceID   FROM ss21_file WHERE filetime < '2015-05-04 22:13:14.000';
        value         | fileindex |               filename                |        filetime         | filesizeinrecords | filesizeinbytes |              sourceid

----------------------+-----------+---------------------------------------+-------------------------+-------------------+-----------------+-----------------------------
-------
-903097975225368365  |     94859 | ss21_20141118020501_1166.DAT | 2014-11-18 02:05:30.109 |              2775 |          490560 | coll_SS21-Group_0_141627273
0_1634
-2781431802746610881 |     94868 | ss21_20141118042502_1175.DAT | 2014-11-18 04:25:30.154 |              1803 |          310688 | coll_SS21-Group_0_141628113
0_1643
-4731211533677294393 |     94878 | ss21_20141118065501_1185.DAT | 2014-11-18 06:55:30.380 |             14745 |         2640848 | coll_SS21-Group_0_141629013

Best regards,
czezz


-- 
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



view thread (11+ messages)  latest in thread

Message-ID: <657111c9.5817f52.5548a8e0.89d25@o2.pl>
Permalink:  ../657111c9.5817f52.5548a8e0.89d25@o2.pl/
Also on:    postgresql.org/message-id/657111c9.5817f52.5548a8e0.89d25@o2.pl

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: czezz@o2.pl
  Subject: Re: display to_timestamp in quotas or convert to char
  In-Reply-To: <657111c9.5817f52.5548a8e0.89d25@o2.pl>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox