Reputation: 131
I am using the query below to check if today is Friday but it keeps returning False. Can someone help?
select case when to_char(now(), 'Day') = 'Friday' then 'True' else 'False'
end
Upvotes: 0
Views: 24
Reputation: 44137
The output of to_char is padded to the length of the longest day name.
select trim(to_char(now(), 'Day'))='Friday';
Upvotes: 1
Reputation: 6723
How about grabbing the day of the week in integer form instead:
SELECT case when extract('dow' from now()) = 5 THEN true else false end;
0 is Sunday, which makes 5 Friday.
Upvotes: 1