Monday as first day of week

Does anyone have a nice scalar function (I am using views) that can set Monday as day 1 of the week, through to Sunday as day 7.
Weekday function would have been great but am using 2012.
I already have a day of the week where Sunday is day 1 of the week so I gues I could use a function to re set all these but didn't know if there was something that people were already were using.
Regards

SELECT DATEDIFF(day, '19000101', SYSDATETIME()) % 7 + 1;
SELECT DATEPART(weekday, DATEADD(day, @@DATEFIRST - 1, SYSDATETIME()));
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence
Thanks Uri your 2nd solution worked for me.
I have now coded it as a function.
Regards

Similar Messages

  • Calendar.app not showing First Day of Week selected in iCal

    I have selected Monday as the first day of the week in iCal. After syncing, Calendar.app on my iPhone 4 does not show Monday as first day of week. My original iPhone 2G (3.1.3, jailbroken) does show the correct start day, Monday.)
    I do not need assistance with my iPhone 2G. I need a solution for my iPhone 4.
    How do I get my iPhone 4 to be in sync with my other calendars?

    That's a real pain. I'm in Australia and the regional settings have Monday as the first week, which throws me out because all my calendars and even settings in iCal have Sunday as the first day of the week (which is what it's supposed to be). To get what I want, I have to set my country as New Zealand, and this messes up my phone number formats (closest to Australia than any of the others that start the week correctly though). It should be an option in the settings!

  • Changing first day of week in Calendar help

    Hi,
    I want to change the first day of week from Monday to Sunday in Webdynpro ABAP screen's default calendar help. I implemented BADI CALENDAR_DEFINITION to change the first day of week, it worked for SAP GUI calendar help but not working for WebDynpro ABAP screen.
    Thanks,
    Alok

    Hi,
    Try using the data type TVDIR-GENDATE for date field. It will populate serach help Calendar and it should trigger the BADI from web dynpro also.
    Refer SAP Help. It is pointing to the same BADI.
    http://help.sap.com/saphelp_nwpi711/helpdata/en/3d/e53642e2a3ab04e10000000a1550b0/frameset.htm
    Thanks,
    Jyothi

  • First day of week in Clock app - Alarm

    I changed the first day of week to Monday in Settings -> Mail, Contacts, Calendars -> Start Week On. However, it still shows Sunday as the first day in Clock -> Alarm -> Repeat -> Weekdays. How can I set Monday in the Clock app? Thanks.

    On 2/13/2013 12:36 AM, thgeiger wrote:
    >
    > Hi,
    > after upgrading from GW8.02 to GW2012SP1 the first day of week in
    > WebAcc and CalPub is Sunday again. Under GW8.02 I had configured the
    > first day as Monday (in a configuration file) Unfortunately I don't
    > remember which file it was?
    > Any ideas?
    > Kind regards,
    > Thomas
    >
    >
    Here's an old post, don't have time to confirm still true
    'm been looking around and trying to find out about the function
    "firstDayOfWeek", but I now finally found out it is much easier than that.
    Solution:
    Find the CssResources_xx.properties file (where xx is the language you
    want to change for) in the
    tomcat\4\webapps\gw\WEB-INF\classes\com\novell\webaccess\templates\css
    directory.
    Look for Calendar.Week.startDay=1 and change that to 2 for Monday. Do
    this for all language properties files you need.
    Stop and start tomcat and voil*.
    Regards,
    Patrick

  • First Day of Week in Data Entry Profile

    Does anyone know if there is a standard SAP RFC i can use in my Web Dynpro application to get the First Day of Week entry in a user's Data Entry Profile?
    Thanks,
    -Kevin

    Hello Kevin,
    Function Module returns the System Date from that SAP System(R/3). I have checked this BAPI with '200743 - current week' GET_WEEK_INFO_BASED_ON_DATE, it returns proper data like Start Date and End Date.
    I Assume, you are using this in your Java WD. You can write your own function for this. This will return the day of the week.
    Calendar xmas = new GregorianCalendar(2007, Calendar.SEPTEMBER, 23);
    int dayOfWeek = xmas.get(Calendar.DAY_OF_WEEK);
    wdComponentAPI.getMessageManager().reportSuccess("Day : "+dayOfWeek);
    Note : - week starts with 0 . 0 - Monday 6 -Saturday.
    Regards,
    Sridhar

  • First day of week in WebAccess and CalendarPublisher

    Hi,
    after upgrading from GW8.02 to GW2012SP1 the first day of week in WebAcc and CalPub is Sunday again. Under GW8.02 I had configured the first day as Monday (in a configuration file) Unfortunately I don't remember which file it was?
    Any ideas?
    Kind regards,
    Thomas

    On 2/13/2013 12:36 AM, thgeiger wrote:
    >
    > Hi,
    > after upgrading from GW8.02 to GW2012SP1 the first day of week in
    > WebAcc and CalPub is Sunday again. Under GW8.02 I had configured the
    > first day as Monday (in a configuration file) Unfortunately I don't
    > remember which file it was?
    > Any ideas?
    > Kind regards,
    > Thomas
    >
    >
    Here's an old post, don't have time to confirm still true
    'm been looking around and trying to find out about the function
    "firstDayOfWeek", but I now finally found out it is much easier than that.
    Solution:
    Find the CssResources_xx.properties file (where xx is the language you
    want to change for) in the
    tomcat\4\webapps\gw\WEB-INF\classes\com\novell\webaccess\templates\css
    directory.
    Look for Calendar.Week.startDay=1 and change that to 2 for Monday. Do
    this for all language properties files you need.
    Stop and start tomcat and voil*.
    Regards,
    Patrick

  • First Day of Week in Gnome Calendar

    One day I noticed that the first day of the week in my gnome calendar is was Monday instead of Sunday.  I have no idea what caused this change, but nothing I can do seems to be able to change it to Sunday.  This is the mini Calendar that pops up when you click on the clock on the panel.  any ideas?

    On 2/13/2013 12:36 AM, thgeiger wrote:
    >
    > Hi,
    > after upgrading from GW8.02 to GW2012SP1 the first day of week in
    > WebAcc and CalPub is Sunday again. Under GW8.02 I had configured the
    > first day as Monday (in a configuration file) Unfortunately I don't
    > remember which file it was?
    > Any ideas?
    > Kind regards,
    > Thomas
    >
    >
    Here's an old post, don't have time to confirm still true
    'm been looking around and trying to find out about the function
    "firstDayOfWeek", but I now finally found out it is much easier than that.
    Solution:
    Find the CssResources_xx.properties file (where xx is the language you
    want to change for) in the
    tomcat\4\webapps\gw\WEB-INF\classes\com\novell\webaccess\templates\css
    directory.
    Look for Calendar.Week.startDay=1 and change that to 2 for Monday. Do
    this for all language properties files you need.
    Stop and start tomcat and voil*.
    Regards,
    Patrick

  • CRM onDemand Calendar - Configure First Day of Week?

    Hi guys,
    by default, the calendar is showing Sunday as the first day of week in the CRM calenadr. is it possible to configure any settings to have monday as the first day?

    Mika, at this time it is not possible to configure the first day of the week.

  • SelectInputDate set first day of week

    Hi all! I was trying to change the first day of week showed in the calendar (Ex. set the first day the Monday) but i dont find any results :(
    Someone know how to change it?
    Many thanks.
    Jose.

    Hi Jose, <br>
    <br>
    Unfortunately, this is not possible in JDeveloper 10.1.3<br>
    See "<a href="http://blogs.oracle.com/Didier/2007/02/26#a218"> Setting the First Day of the Week to Monday in the SelectInputDate component</a>" for more details. <br>
    <br>
    Regards, <br>
    <br>
    Didier.<br>
    <br>

  • ESS: Change First Day of Week in Date Navigator

    G'day everyone,
    We are on NW2004S, i.e. ECC6 + EP7 + ESS 1.0. I'm having a hard time getting the Date Navigator, i.e. the value help for date fields in ESS, to use Monday rather than Sunday as first day of the week.
    I have managed to customise the Team Calendar (and the other calendars in ESS) to start on Monday rather than Sunday by changing the FirstDayOfWeek property of the calendar element using <Ctrl>-right-mouse-click in Portal Content administration, so that displays ok now.
    However, trying to do the same for the date navigator, i.e. doing a <Ctrl>-right-mouse-click just makes the date navigator disappear (actually it happens the moment I press the <Ctrl> key).
    Am I doing something wrong here? Is there any other way to customise the FirstDayOfWeek property of the Date Navigator of WebDynpro for JAVA iViews in EP7?
    Thanks a lot for your help and best regards!
    Andree

    On 2/13/2013 12:36 AM, thgeiger wrote:
    >
    > Hi,
    > after upgrading from GW8.02 to GW2012SP1 the first day of week in
    > WebAcc and CalPub is Sunday again. Under GW8.02 I had configured the
    > first day as Monday (in a configuration file) Unfortunately I don't
    > remember which file it was?
    > Any ideas?
    > Kind regards,
    > Thomas
    >
    >
    Here's an old post, don't have time to confirm still true
    'm been looking around and trying to find out about the function
    "firstDayOfWeek", but I now finally found out it is much easier than that.
    Solution:
    Find the CssResources_xx.properties file (where xx is the language you
    want to change for) in the
    tomcat\4\webapps\gw\WEB-INF\classes\com\novell\webaccess\templates\css
    directory.
    Look for Calendar.Week.startDay=1 and change that to 2 for Monday. Do
    this for all language properties files you need.
    Stop and start tomcat and voil*.
    Regards,
    Patrick

  • Function Modules to get First day of week, month, Year

    Can anyone name the Function Modules for getting First day of week, month ,year.

    to get first day of week use this function;   WEEK_GET_FIRST_DAY
          CALL FUNCTION 'WEEK_GET_FIRST_DAY'
               EXPORTING
                    WEEK         = '201107'
               IMPORTING
                    DATE         = l_date
               EXCEPTIONS
                    WEEK_INVALID = 1
                    OTHERS       = 2.
    with DATE_COMPUTE_DAY function you can get date number in week.
    CALL FUNCTION 'DATE_COMPUTE_DAY'
           EXPORTING
                DATE = workdate
           IMPORTING
                DAY  = day_of_week_num
           EXCEPTIONS
                OTHERS  = 8.
      CASE day_of_week_num.
        WHEN 1.
          hold_day_of_week = 'Monday'.
        WHEN 2.
          hold_day_of_week = 'Tuesday'.
        WHEN 3.
          hold_day_of_week = 'Wednesday'.
        WHEN 4.
          hold_day_of_week = 'Thursday'.
        WHEN 5.
          hold_day_of_week = 'Friday'.
        WHEN 6.
          hold_day_of_week = 'Saturday'.
        WHEN 7.
          hold_day_of_week = 'Sunday'.
        WHEN OTHERS.
          hold_day_of_week = 'invalid'.
      ENDCASE.

  • Deriving first day of week ww in year yyyy

    I need to be able to display the first day of a particular week in addition to the 'week-of-year' and year; for example:
    select to_char("ServiceDate",'yyyy-ww') as "Year/Week", sum("Points") as "Points"
    from my_table
    group by to_char("ServiceDate",'yyyy-ww')
    order by to_char("ServiceDate",'yyyy-ww')will give me the following:
    Year/Week     Points
    2008-33            1                     
    2008-35            1                     
    2008-42            4                     
    2008-43            2                     
    2009-01            1                     
    ...and so forth. What I would like to add to the dataset is the actual day that is the first day of the week for that Week/Year. For example, the first row would look like this:
    Year/Week     1st day of week     Points
    2008-33          08-AUG-2008*         1*Or whatever the first day of week 33 of year 2008 is (assuming 'first day of week' is a Sunday, for my purposes).
    My brain is on 'dim' right now; any and all assistance is greatly appreciated.
    Thanks in advance,
    Carl

    select  to_char(trunc("ServiceDate",'ww'),'yyyy-ww') as "Year/Week",
            to_char(trunc("ServiceDate",'ww'),'DD-MON-YYYY') "Week Start Date",
            sum("Points") as "Points"
    from my_table
    group by trunc("ServiceDate",'ww')
    order by trunc("ServiceDate",'ww')
    /SY.

  • Date Breakup with Monday First Day of Week for Fortnight

    Post Author: Guggu
    CA Forum: Formula
    Hi,
    I am using a cross tab and I am trying to break up the data by the reporting periods we use, which is 2 weeks and is from Monday of Week 1 to Sunday of week 2.
    I use the GROUP OPTIONS in Crystal report XI and tell it ot show FOR EACH TWO WEEKS but shows the dates with SUNDAY the first day of the week.
    I had some BASIC SYNTAX which used to work in v8.5 and some times works for XI but not this time, so i would like to know if there is a better way to work this out as all my reports need to be done this way.
    The BASIC SYNTAX i had was:
    Dim ew1 As Date Dim rosterdate As Date Dim i As Number Dim fortnight As Date  rosterdate = cdate({?StartDate}) + 70 ew1 = cdate({?StartDate}) ew1 = ew1 + 13 For i = 1 To 10
        If rosterdate <= ew1 Then        fortnight = ew1        formula = fortnight        Exit For     End If
        ew1 = ew1 + 14Next i
    But this is not working anymore.
    Can someone please help.
    Kindest Regards,
    George

    I just realized that the .../CatalystScripts/Java_DatePicker.js was modified on April 1st, but not by me. Did you do that?
    The weekdays were sorted by Monday to Sunday, but the number of the days were not right. So today it showed Tuesday the 6th of April (of course it should be Monday).
    My client just contacted me, that they have a mess with the reservations, people did reservations with the wrong date
    I already changed it to the previous version. I think, I will implement a jQuery-datepicker, the BC datepicker is not flexibel enough.

  • First Day of Week

    Hi Guys,
    In a class I have an object which shows the date when a transaction was triggered and another object which gives the week number in the format wwyyyy.
    I want to create a variable in the report which will give me the starting day for that particular week i.e the date that was there on Monday of that particular week.
    It can be easily done by making changes in the Universe but I want to do it in the report as this is a one of report.
    Cheers,
    Shazin

    Guys,
    I have devised a method for the below and we can easily find out the week numbers of the month as below:
    Week Numb:
    =Week([WO's Last Month ].[Submit Date])
    First Day of the Month:
    =Week(RelativeDate(LastDayOfMonth(RelativeDate(LastDayOfMonth(CurrentDate());-65));1))
    Week Numb of the Month:
    =Concatenation("Week : ";([Week Numb - WO's Last Month]-[Last Day - WO's Last Month])+1)
    Please let me know if in case any queries.
    Cheers,
    Shaz

  • Forms 6i Bad first day of week

    Hello,
    Please help me
    We have oracle form 6i application in our organization, in the past we had the same app but the database was 9i (9.2.0.1) and we migrate the database to 10g (10.2.0.1) with the same NLS parameters, the problem is there are forms calculating the first day of the week based in the query :
    SELECT TO_CHAR(TO_DATE('03/01/2005','DD/MM/YYYY'),'D')
    FROM
    DUAL;
    this query through the sqlplus (ORACLE_HOME form 6i) return 2
    using sqltools client with and without tnsname return 2
    in the server using sqlplus with and without tnsname return 2
    but when rhe form insert data into data base insert a wrong value the Monday(2) insert as Sunday(1)
    INSTANCE
    PARAMETER     VALUE
    NLS_LANGUAGE     AMERICAN
    NLS_TERRITORY     AMERICA
    NLS_SORT
    NLS_DATE_LANGUAGE
    NLS_DATE_FORMAT
    NLS_CURRENCY
    NLS_NUMERIC_CHARACTERS
    NLS_ISO_CURRENCY
    NLS_CALENDAR
    NLS_TIME_FORMAT
    NLS_TIMESTAMP_FORMAT
    NLS_TIME_TZ_FORMAT
    NLS_TIMESTAMP_TZ_FORMAT
    NLS_DUAL_CURRENCY
    NLS_COMP
    NLS_LENGTH_SEMANTICS     BYTE
    NLS_NCHAR_CONV_EXCP     FALSE
    DATABASE
    PARAMETER     VALUE
    NLS_LANGUAGE     AMERICAN
    NLS_TERRITORY     AMERICA
    NLS_CURRENCY     $
    NLS_ISO_CURRENCY     AMERICA
    NLS_NUMERIC_CHARACTERS     .,
    NLS_CHARACTERSET     WE8ISO8859P1
    NLS_CALENDAR     GREGORIAN
    NLS_DATE_FORMAT     DD-MON-RR
    NLS_DATE_LANGUAGE     AMERICAN
    NLS_SORT     BINARY
    NLS_TIME_FORMAT     HH.MI.SSXFF AM
    NLS_TIMESTAMP_FORMAT     DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT     HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT     DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY     $
    NLS_COMP     BINARY
    NLS_LENGTH_SEMANTICS     BYTE
    NLS_NCHAR_CONV_EXCP     FALSE
    NLS_NCHAR_CHARACTERSET     AL16UTF16
    NLS_RDBMS_VERSION     10.2.0.1.0
    CLIENTES FORMS REGEDIT KEY NLS_LANG
    LATIN AMERICAN SPANISH_AMERICA.WE8ISO8859P1
    Thank foy your help, and sorry for my English

    Gerd, that German Weekday function is nice. I looked it over and tried out various things, especially those suggested by JWH and Laurent Schneider in the comments. Using JWH's method, I came up with this function below.
    I have tried it out with every NLS_Territory setting I can find, and it works everywhere:
      Function week_day_standard(d in date) return number is begin
      -- This function returns a value from 1 to 7 identifying
      -- the day of the week, where Monday is always 1, and
      -- Sunday is 7.
      -- In Oracle, depending on the NLS_Territory setting,
      --   different days of the week are 1.
      -- Examples:
      --   U.S., Canada, Monday = 2;  Most European countries, Monday = 1;
      --   Most Middle-Eastern countries, Monday = 3.
      --   For Bangladesh, Monday = 4.
        Return 1 + mod(to_number(to_char(d,'J')),7);
      End week_day_standard;And here is a SQL Plus script I used to verify the function:
    clear screen
    Declare
      S  varchar2(1);
      M  varchar2(1);
      Function week_day_standard(d in date) return number is begin
      -- This function returns a value from 1 to 7 identifying
      -- the day of the week, where Monday is always 1, and
      -- Sunday is 7.
      -- In Oracle, depending on the NLS_Territory setting,
      --   different days of the week are 1.
      -- Examples:
      --   U.S., Canada, Monday = 2;  Most European countries, Monday = 1;
      --   Most Middle-Eastern countries, Monday = 3.
      --   For Bangladesh, Monday = 4.
        Return 1 + mod(to_number(to_char(d,'J')),7);
      End week_day_standard;
      procedure go3 (d1 date) is
       d date := d1;
      begin
        loop
          d := d+1;
          DBMS_Output.Put_Line('          '
           ||       to_char(d,'Dy, mm-dd-yyyy D')
           ||'  '|| to_char( d+1-trunc(d,'iw') )
           ||''  || week_day_standard(d)
           ||''  || to_char(1+mod(to_number(to_char(d,'J')),7))
           ||'  '|| to_char(trunc(d,'iw'),'mm-dd-yyyy')  );
          exit when to_char(d,'mmdd')='0104';
        end loop;
        DBMS_Output.Put_Line(' ');
      end go3;
      procedure go2 is begin
        go3(DATE'2004-12-26');
        go3(DATE'2005-12-25');
        go3(DATE'2006-12-24');
        go3(DATE'2007-12-30');
        go3(DATE'2008-12-28');
        go3(DATE'2009-12-27');
      end go2;
      procedure go(T varchar2) is begin
        execute immediate('alter session set nls_territory='''||T||'''');
        S := TO_CHAR(TO_DATE('07/20/2008','MM/dd/YYYY'),'D'); -- sunday, July 20, 2008
        M := TO_CHAR(TO_DATE('07/21/2008','MM/dd/YYYY'),'D'); -- Monday, July 21, 2008
        DBMS_Output.Put_Line('  '||S ||'   '||M||'   '||rpad(T,16) );
        go2;
      End go;
    Begin
      DBMS_Output.Put_Line(chr(10)||' Sun Mon Territory' || chr(10)||' --- --- -----------');
      Go('UNITED KINGDOM');
      Go('MOROCCO');
      Go('BANGLADESH');
      Go('AMERICA');
    End;
    /

Maybe you are looking for

  • Linux Server to connect Windows 2008 R2 Server to execute powershell commands

    Is it possible to do remotely executing powershell scripts on Windows 2008 R2 from Linux Server. I explored the option of FreeSSHD, but there is no option for password less authentication. Any thoughts and hints greatly appreciated. Retheesh Thanks a

  • Aperture Library Sizee

    I have created a new Aperture library, containing about 225,000 photos. I imported all of the photos as reference files...leaving them in their current locations. Nonetheless, my Aperture library file is enormous, at 125 GB. Since I didn't copy the p

  • Creating editable report

    All, I trying to create editable report that has edit button in every record and if you click the edit button that same row changes to editable(text field) where you can update the data without redirecting you to edit form and then allow you save cha

  • IOS 8.0.2 - Calendar app no longer syncing Exchange

    Hello! I've recently purchased an iPhone 6. After restoring through iTunes everything was now on my new phone. Awesome. Everything worked perfectly, mail accounts were synced, calendar worked. I then updated my phone to iOS 8.0.2 and all of a sudden

  • Can I manually add music WITHOUT 'Erasing and Syncing'

    I've always been able to import individual songs from my iMac to my iPhone - however, I recently got a MacBook, and now all I'm able to do is create a new playlist under the little "iPhone" badge that appears once you connect it to the computer. Like