I have a json containing day names as keys and I'm trying to select the value from the json using today as a key, where today is Thursday. However this does not work as intended.
SELECT hoursJson->'normalHours'->'Thursday' FROM BusinessHours;
returns the hours contained in the json correctly, but
SELECT hoursJson->'normalHours'->to_char(current_date, 'Day') FROM BusinessHours;
returns nothing.
Why is to_char(current_date, 'Day') not equal to 'Thursday'
when used as a json key? to_char() returns text so I don't know why these two keys aren't equal. How do I make them equal so I can use to_char() as a json key?
Thanks!
to_charblank-pads the return value when you use'Day'so...->to_char(current_date, 'Day')will only work properly on Wednesday (in an English locale too of course).