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

Index on timestamp to date field

P: n/a
I have a timestamp field where I find I'm doing a lot of searching by date
(YYYY-MM-DD) or using this field as a match to another table that has a
date format. I wanted to create an index on the timestamp field using a
date format. Is this possible? I tried:
CREATE INDEX test_2 ON table1 USING btree to_char(field2, 'MM-DD-YYYY');
but I get an error message error at or new to_char

TIA

Patrick Hatcher
Macys.Com
Legacy Integration Developer
415-422-1610 office
HatcherPT - AIM
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

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

Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Mon, Oct 13, 2003 at 13:49:07 -0700,
Patrick Hatcher <PH******@macys.com> wrote:
I have a timestamp field where I find I'm doing a lot of searching by date
(YYYY-MM-DD) or using this field as a match to another table that has a
date format. I wanted to create an index on the timestamp field using a
date format. Is this possible? I tried:
CREATE INDEX test_2 ON table1 USING btree to_char(field2, 'MM-DD-YYYY');
but I get an error message error at or new to_char


You can't create general functional indexes until 7.4.
However you might be able to use an index on the timestamp if you cast
the character strings to a timestamp value.

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #2

P: n/a
On Mon, 13 Oct 2003, Patrick Hatcher wrote:
I have a timestamp field where I find I'm doing a lot of searching by date
(YYYY-MM-DD) or using this field as a match to another table that has a
date format. I wanted to create an index on the timestamp field using a
date format. Is this possible? I tried:
CREATE INDEX test_2 ON table1 USING btree to_char(field2, 'MM-DD-YYYY');
but I get an error message error at or new to_char

TIA


So you don't want a oh. lets call it a "real index" on the timestamp
field?

create index ts_index on mytable(mytimestamp);

Or can you not change the way the dates are input?

Or is the "mytimestamp" field a varchar containing a date string?

--
Jeff Trout <je**@jefftrout.com>
http://www.jefftrout.com/
http://www.stuarthamm.net/

---------------------------(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 12 '05 #3

P: n/a
On Mon, 13 Oct 2003, Patrick Hatcher wrote:
I have a timestamp field where I find I'm doing a lot of searching by date
(YYYY-MM-DD) or using this field as a match to another table that has a
date format. I wanted to create an index on the timestamp field using a
date format. Is this possible? I tried:
CREATE INDEX test_2 ON table1 USING btree to_char(field2, 'MM-DD-YYYY');
but I get an error message error at or new to_char

TIA


So you don't want a oh. lets call it a "real index" on the timestamp
field?

create index ts_index on mytable(mytimestamp);

Or can you not change the way the dates are input?

Or is the "mytimestamp" field a varchar containing a date string?

--
Jeff Trout <je**@jefftrout.com>
http://www.jefftrout.com/
http://www.stuarthamm.net/

---------------------------(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 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.