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;
He gives me weekday information as text . Then I use:
select date::date, weekday::varchar from datetoday;
Now the table is similar to
2013-3-1 Friday 2013-3-2 Saturday
If I want to select an entry:
select * from datetoday where weekday='Friday'
to change it from text to character varying .
It seems that the length is not fixed for each word length.
For example, "Friday" should have a length of 6 and a length of Wednesday 9.
How can I change this, let the length be the actual word length?
Because later I will compare the weekday column with another weekday column. how
where a.weekday=b.weekday
Another day of the week is from the user from jsp, so the length varies.
Now the length is fixed, the comparison is not performed.
sql postgresql database-design date-format generate-series
user3382017 Mar 07 '14 at 5:24 2014-03-07 05:24
source share