I generate a view from this:
create or replace view datetoday as
select to_char(dt, 'yyyy-mm-dd') as date, to_char(dt, 'Day') as weekday from
(select ('2013-03-01'::date + i) dt from generate_series(0,'2013-03-03'::date - 2013-03-01'::date)
as t(i)) as t;
It gives me the weekday info as text
type. Then I use:
select date::date, weekday::varchar from datetoday;
Now the table is like
2013-3-1 Friday
2013-3-2 Saturday
If I want to choose the entry:
select * from datetoday where weekday='Friday'
to change it from text
to character varying
.
It seems that the length is fixed is not according to each word length.
For example 'Friday' should have length 6 and Wednesday length 9.
How can I change this, let the length be the actual length of the word?
Because later I will compare this table's weekday
column to another table's weekday
column. Like
where a.weekday=b.weekday
The other weekday is from user from jsp, so the length varies.
Now the length is fixed, the comparison fails.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…