Martin
1
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: :man_shrugging:](https://community.baserow.io/images/emoji/twitter/man_shrugging.png?v=12)
I have got version 1.21.2, selfhosted.
Alex
2
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.
Martin
3
Hi Alex,
first, I had written everything with a capital letter at the beginning …
It was the same result.
Alex
4
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?
Alex
5
@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](https://community.baserow.io/uploads/default/original/2X/d/d9ddc4dfc32002d1ce46ce68e6031c58c7ea9424.png)
davide
6
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.
Martin
7
Hi, Davide,
ok, thank you.