datepart(dw,getdate())

  • datepart (dw,getdate()) returns daynumber of today, but default with sunday beiing day 1. I want monday beiing day1, ok by using set datefirst, but this is only for the current session. How to set the default to monday being 1? I tried to update syslanguages system table (all languages have now datefirst=1), but still, starting a new connetion, default setting for @@datefirst is 7 (=sunday) instead of 1 (= monday).

    Any idea?

  • Check out BOL for DATEPART and SET DATEFIRST.

    Use:

    
    
    SET DATEFIRST 1
    SELECT DATEPART(dw, GETDATE())
  • OK, as I said, datefirst is an option. But ONLY FOR CURRENT SESSION !!! I want default behaviour to be monday as day 1, I don't want to use datefirst on begin of every new session.

  • OK, in BOL, the article says:

    quote:


    Remarks

    Use the @@DATEFIRST function to check the current setting of SET DATEFIRST.

    The setting of SET DATEFIRST is set at execute or run time and not at parse time.


    I could find no evidence that @@DATEFIRST can be set on a server or database level.

  • JPipes is correct, unfortunately with the current versions of SQL Server, many of the date settings can only be set for the current connection, and not as a default for the entire server.

  • So the 'datefirst' column in the syslanguages (master) is not taken into account. Is it used for something else, or is it just there ?

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply