Weekday() function does not work properly

Hi all,
i'm using Metabase 0.47.5 hosted on Docker with postgres as application database, and sql-server as source database to analize.
I am using the weekday() function to deduce the day of the week on which orders are placed.
The documentation says that:

### weekday
Takes a datetime and returns an integer (1-7) with the number of the day of the week.
weekday([Created At]) = 1, "Sunday",
weekday([Created At]) = 2, "Monday",
weekday([Created At]) = 3, "Tuesday",
weekday([Created At]) = 4, "Wednesday",
weekday([Created At]) = 5, "Thursday",
weekday([Created At]) = 6, "Friday",
weekday([Created At]) = 7, "Saturday")

So I assume that 1= Sunday etc. But when i use a custom column to get the weekday of my orders, i get the following response (see the attached screenshot for further details):

Monday 23/10/2023 has WeedDay 1, but i expected 2, based on documentation., and so on for all the records.

In the Admin Settings, section Localization I've found the following setting, regarding the first day of the week:

I assume that FIRST DAY OF WEEK -> Sunday so Orders created on Sunday -> weekday(Sunday) = 1, Orders created on Monday -> weekday(Monday) = 2.

Is my statement correct? I'm doing something wrong or is this a bug?
Thank you,

Here is my troubleshooting information:

  "browser-info": {
    "language": "it-IT",
    "platform": "Win32",
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36",
    "vendor": "Google Inc."
  "system-info": {
    "file.encoding": "UTF-8",
    "java.runtime.name": "OpenJDK Runtime Environment",
    "java.runtime.version": "",
    "java.vendor": "Eclipse Adoptium",
    "java.vendor.url": "https://adoptium.net/",
    "java.version": "",
    "java.vm.name": "OpenJDK 64-Bit Server VM",
    "java.vm.version": "",
    "os.name": "Linux",
    "os.version": "",
    "user.language": "en",
    "user.timezone": "Europe/Rome"
  "metabase-info": {
    "databases": [
    "hosting-env": "unknown",
    "application-database": "postgres",
    "application-database-details": {
      "database": {
        "name": "PostgreSQL",
        "version": "15.1 (Debian 15.1-1.pgdg110+1)"
      "jdbc-driver": {
        "name": "PostgreSQL JDBC Driver",
        "version": "42.5.4"
    "run-mode": "prod",
    "version": {
      "date": "2023-10-20",
      "tag": "v0.47.5",
      "branch": "?",
      "hash": "e7ee12e"
    "settings": {
      "report-timezone": "Europe/Rome"

What happens if you change the weekday in the settings?

Hi Luiggi,
if i set "FIRST DAY OF THE WEEK" on Sunday the weekday() function return 1 on Monday 23/10/2023 date (expected: 2).
if i set "FIRST DAY OF THE WEEK" on Monday the weekday() function return 7 on Monday 23/10/2023 date (expected: 1).
It seems that the function counts the days in this order: 7-1-2-3-4-5-6 and not 1-2-3-4-5-6-7. The "FIRST DAY OF THE WEEK" parameter set as 7 the chosen day.

Any news? Can you confirm this is unintentional and so can be considered as a bug?