Day of the week cannot be read correct?

Hi,

I want to translate the day of the week into german [field Wochentag (Deutsch)] by the following formula:

if(field('Wochentag (engl.)')='saturday','Samstag',if(field('Wochentag (engl.)')='sunday','Sonntag',if(field('Wochentag (engl.)')='monday','Montag',if(field('Wochentag (engl.)')='tuesday','Dienstag',if(field('Wochentag (engl.)')='wednesday','Mittwoch',if(field('Wochentag (engl.)')='thursday','Donnerstag',if(field('Wochentag (engl.)')='friday','Freitag','')))))))

When my field Wochentag (engl.) is a text field everything works fine.
But if that field is a formula field with

datetime_format(field('Beginn'),'day')

I just get an output for wednesday?!?
:man_shrugging:

I have got version 1.21.2, selfhosted.

Have you tried using capital letters in the comparison?

wednesday became Wednesday when you used the formatting, so it might just be a case sensitive mismatch.

Hi Alex,
first, I had written everything with a capital letter at the beginning …
It was the same result.

Yeah I see, I can reproduce your issue. My guess is that this might have to do something with our type system in formula land.

@davide can someone on the database team look into that?

@davide it looks like we add a bunch of spaces when we use the format function. That’s probably the issue (see field_1570759):

image

Hey @Martin,

I can reproduce the issue and confirm that @Alex is correct. The problem is those extra spaces that should not be there.

I’ve created an issue here: datetime_format formula function adds spaces at the end of the strings (#2131) · Issues · Baserow / baserow · GitLab

In the meantime, I think you could get around this problem with the replace function with something like:

replace(datetime_format(field('Date'), 'day'), ' ', '')

In this way you can replace all the spaces with an empty string, so the comparison will work as expected.

Hi, Davide,
ok, thank you.