How to find first day of the year

Big picture: trying to determine how many pay periods are left in the year. There are 52 weeks in a year, and our company pay out each week.
The first pay week of the year always starts on a Friday. So If Janurary 1 is a friday, then the 1st week of pay period starts that week. If Jan 1 is a Thursday, then the first pay week will start on Janurary 2.
I need to figure out what day the first day of any year it is. By day, i mean Mon, Tue, Wed, Thur, Fri, Sat, or Sun.
Then when I figure out what day it is, i will write an if/then statement saying if Jan 1 is a monday, then add 4 days to that date and that will be the first day of a pay period.
Then when i figure out the first day of the first week, I wanted to add 7 days to create week2, week3.... week 52.
Then take todays date and if it was between week x and week y, then it would determine that z many pay periods are left...
is this the best way to go about this? anything easier?

You can use the getDay method of a Date object to determine the day of the week. Any decent JavaScript reference will have more information.
George

Similar Messages

  • Find first day of any year

    How to find first day of any year using sql? Is there any function for it ?

    Using below SQL you have to just pass the year:
    SQL> select to_char(to_date('0101'||&tyear, 'ddmmyyyy'), 'Day') from dual;
    Enter value for tyear: 2000
    old   1: select to_char(to_date('0101'||&tyear, 'ddmmyyyy'), 'Day') from dual
    new   1: select to_char(to_date('0101'||2000, 'ddmmyyyy'), 'Day') from dual
    TO_CHAR(T
    Saturday
    SQL> /
    Enter value for tyear: 2001
    old   1: select to_char(to_date('0101'||&tyear, 'ddmmyyyy'), 'Day') from dual
    new   1: select to_char(to_date('0101'||2001, 'ddmmyyyy'), 'Day') from dual
    TO_CHAR(T
    Monday
    SQL> /
    Enter value for tyear: 1990
    old   1: select to_char(to_date('0101'||&tyear, 'ddmmyyyy'), 'Day') from dual
    new   1: select to_char(to_date('0101'||1990, 'ddmmyyyy'), 'Day') from dual
    TO_CHAR(T
    MondayRegards

  • Dynamic Variant for First Day of the Year

    Hello All,
    When I am trying to change the variant field related to date, i couldnot find out variant attribute for the FIRST DAY OF THE YEAR.
    Is it possible to add one more attribute FIRST DAY OF THE YEAR just like attributes which are existing.(Current date, First day of the month .. etc are already existing.)
    If it is possible,could anyone please post the procedure for this..?
    Thanks and regards,
    Mervin Mathew

    Hi,
    unfortunatelly there is not such option.
    If this is customer report, You can set initial date in INITIALIZATION event:
    INITIALIZATION.
      CLEAR: so_date, so_date[].
      so_date-sign = 'I'.
      so_date-option = 'GE'.
      so_date-low = sy-datum.
      so_date-low+4(4) = '0101'.
      APPEND so_date.
    Regards,
    Przemysław

  • How to show all days of the year 1900

    how to show all days of the year 1900

    As you show days for any other year.
    Do you want to catch us on the fact year 1900 wasn't a leap year?
    Regards
    Etbin
    select to_date('1.1.' || :the_year,'DD.MM.YYYY') + level - 1
      from dual
    connect by level <= to_date('31.12.' || :the_year,'DD.MM.YYYY') - to_date('1.1.' || :the_year,'DD.MM.YYYY') + 1*** not tested ***
    Message was edited by: Etbin
    user596003

  • Default parameter to first day of the year

    Hi,
    I am looking to put default value of the parameter to first day of the year. Help me
    Thanks
    susheel 
    sush

    Use this expression as Default Value for parameter:
    =DateSerial(YEAR(Today()), 1, 1)
    - Vishal
    SqlAndMe.com

  • How to get last day of the year

    Hi All ,
    Thanks in advance ...
    How will I get the last day of the year as I am passing date at run time .
    I can manage to get first day of year by
    SELECT TRUNC(SYSDATE,'YEAR') AS FDAY_YEAR
    from dual
    Thanks in advance
    Regards
    Sachin

      1*  select ADD_MONTHS(trunc(sysdate,'yyyy'),12)-1 dd from dual
    SQL> /
    DD
    31-DEC-2010

  • Need the first day of the year and last day of the year.

    hi all,
    i need a function module which can get me the first day of current year and last day of the current year??
    please help.

    Similar date questions are being asked ALL THE TIME.  Please search.

  • Function for finding first day of the month !!

    Hi,
    I know we have function to find the last day(DD) of the month. Do we have any functions for finding the first day of the month ??? if not is there any way i can find the first date(DD) of the month .
    Bcoz i m trying to incorporate the logic for finding the first day of the month partition.
    Thank you!!!

    Shahid Ali Tcs wrote:
    There are many solution given by member in relation with your question, and all are correct .
    I want to make u know something else.
    Have you ever think why oracle has given function for last_day but no function for first.....
    I u think this question u will get the answer of your "first day finding " question.
    Because first day is alwasy 01 of every, while last day can be 30,31,29,28.....
    Got my words ........
    One more solution from my side,,,,
    SQL> select '01' || to_char(sysdate,'-MON-YY') from dual;
    '01'||TO_
    01-SEP-09Which is a completely poor way of doing it.
    Using TRUNC or LAST_DAY(..) + 1 will return a DATE datatype result.
    Your method is converting the DATE into a VARCHAR2, which then prevents further processing/date based calculations unless it is explicitly converted back to a DATE again.
    The reason Oracle hasn't provided a FIRST_DAY is because the TRUNC function already caters for it as this works with DATE's as well as NUMBER's, not because the first day is always 1.

  • How to get first day of the month by the given date?

    Now, is there function in CRM system that can get the first day of the month ?
    for example:
        input date is 2007/12/12, then return 2007/12/01 (the first day of month).
    Thank you~

    Hi ping,
    data: w_date type sy-datum ,
             w_temp(2) type c.
    w_date = '20071212'.
       w_temp = w_date+6(2).
       w_temp = w_temp - 1.
       w_date = w_date - w_temp.
    write / w_date.
    Plz Reward if useful,
    Mahi.

  • How to - get first DAY of the month from the date ?

    Hi
    pls help

    hi,
    data : DAYNR LIKE HRVSCHED-DAYNR,
    DAYTXT LIKE HRVSCHED-DAYTXT.
    data langu like sy-langu value 'EN'.
    Parameters PDATE LIKE SY-DATUM.
    PDATE+6(02) = '01'.
    CALL FUNCTION 'RH_GET_DATE_DAYNAME'
    EXPORTING
    LANGU = LANGU
    DATE = PDATE
    CALID =
    IMPORTING
    DAYNR = DAYNR
    DAYTXT = DAYTXT
    DAYFREE =
    EXCEPTIONS
    NO_LANGU = 1
    NO_DATE = 2
    NO_DAYTXT_FOR_LANGU = 3
    INVALID_DATE = 4
    OTHERS = 5
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    WRITE :/ PDATE, DAYNR, DAYTXT.
       (OR)
    Try..
    DATA:DAYNR  LIKE  HRVSCHED-DAYNR,
         DAYTXT LIKE  HRVSCHED-DAYTXT,
         DAYFREE LIKE  HRVSCHED-NODAY.
    DATA:LANGU LIKE  SY-LANGU ,
         DATE LIKE  SY-DATUM,
         CALID LIKE  P1027-CALID VALUE 'US'.
    date = sy-datum.
    date+6(2) = 01.           "----->to get the first day .
    *first day of the month
    write:/ 'First date of the month', date.
    *Day name
    CALL FUNCTION 'RH_GET_DATE_DAYNAME'
      EXPORTING
        langu                     = SY-LANGU
        date                      = DATE
        CALID                     = CALID
    IMPORTING
       DAYNR                     = DAYNR
       DAYTXT                    = DAYTXT
       DAYFREE                   = DAYFREE
    EXCEPTIONS
       NO_LANGU                  = 1
       NO_DATE                   = 2
       NO_DAYTXT_FOR_LANGU       = 3
       INVALID_DATE              = 4
       OTHERS                    = 5
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    WRITE:/ DAYTXT.
    Don't forget to reward if useful....

  • How to set first day of the week?

    I'm trying to set up my iPad calendar so that my week view starts on Monday. My calendar on my desktop & MoblieMe starts the week on Monday which is what I want but my iPad starts on Sunday (even though it has been synced with my desktop & MoblieMe too). Please help! Thanks!

    Actually, I tried both UK and Australia, and Sunday was still the first day of the week.
    HOWEVER!!!
    Woohoo!!   American Samoa works, and doesn't seem to change any other formats (although admittedly I have not made an exhaustive search - just checked the International Example thing recommended by Matthias suggested.
    Matthias, thanks very much by the way!! 
    OZones

  • TO FIND LAST DAY OF THE YEAR

    I am trying to get last day of the year, is oracle provide any inbuilt function to get this otherwise I am using the below mention query is fine.
    select last_day(to_date('01'||'/'||'12'||'/'||to_char(sysdate,'YYYY'),'DD/MM/YYYY')) from dual
    Thx
    Shishu Paul

    Hi!
    I would prefer using
    select to_date('31'||'/'||'12'||'/'||to_char(sysdate,'YYYY')) from dual;
    since it is not likely that the last day of any year in near future will be anything else than December 31st.
    Regards,
    Petra

  • How to find a day in the next 27 days

    Hi,
    How to find a date = 'Wednesday" in the next 27 days? The below script doesnt work. Could anyone tell me what is the problem with this code? I suspect that the WHERE clause that make the error!
    SELECT TO_DATE(SYSDATE+ROWNUM, 'DD-MON-YY')
    FROM DUAL CONNECT BY ROWNUM <= 27
    WHERE TO_CHAR(DAY, 'DAY') = 'SUNDAY'

    johnsyns wrote:
    Why it doesn't work for the other days? When i tried to change the days other than wednesday. it return nothing.
    Reason why Justin's code does not work for other days is date format mask DAY returns day blank padded to 9 characters which is the longest day name which, yes you guessed right, is WEDNESDAY. You either need to blank pad or use format modifier FM:
    SQL> select *
      2    from (SELECT TO_DATE(SYSDATE+ROWNUM, 'DD-MON-YY') dt
      3            FROM DUAL CONNECT BY ROWNUM <= 27)
      4  WHERE TO_CHAR(dt,'DAY') = 'TUESDAY'
      5  /
    no rows selected
    SQL> select *
      2    from (SELECT TO_DATE(SYSDATE+ROWNUM, 'DD-MON-YY') dt
      3            FROM DUAL CONNECT BY ROWNUM <= 27)
      4  WHERE TO_CHAR(dt,'DAY') = 'TUESDAY  '
      5  /
    DT
    07-APR-09
    14-APR-09
    21-APR-09
    28-APR-09
    SQL> select *
      2    from (SELECT TO_DATE(SYSDATE+ROWNUM, 'DD-MON-YY') dt
      3            FROM DUAL CONNECT BY ROWNUM <= 27)
      4  WHERE TO_CHAR(dt,'FMDAY') = 'TUESDAY'
      5  /
    DT
    07-APR-09
    14-APR-09
    21-APR-09
    28-APR-09
    SQL> SY.

  • How to find compensation data for the year

    Dear All,
    Scenario:
    A company wants to know the comepnsation data for financial year 2009-2010.
    Problem: I couldnot find a single report which can provide the compensation of an employee for the year.
    We are trying to build a report however needs input if anyone has done that:
    Table which stores this data is PS_COMPENSATION.
    Problem is : it stores data in effective date.
    How to then convert it into a year -April 2010 to March 2011
    For example: cases
    a. existing employee: whose effective comp data will be less than April 2010
    - Plus, there are pay rate changes between April 2010 to march 2011. (Pay rate change can happen on any date of the month)
    - How can I add them to find the Compensation as per comp page from 1st April to 31st march 2011

    I'm afraid what you're looking for is not likely to be a trivial task. If you have all of the modules required for the "Report Total Compensation" product, then you should take a look at the associated PeopleBook. I think you will have to be on HRMS 9.0 at a minimum, and using Payroll for North America and Benefits Administration.
    To create a custom solution, you may have to consider a variety of other factors such job status--leave, terminated, terminated with pay, etc.--hourly vs. salaried, part time vs. full time, multi-job, variable compensation. It will depend entirely on the specific features that are being used at your site.
    If you provide a very detailed example of the output you are looking for with sample data, someone might be willing to offer a solution.
    Regards,
    Bob

  • Function Module to get first day of the fiscal year on passing a date

    Hi Experts!!
    Can you please suggest a Function Module to get first day of the fiscal year on passing a date..?
    Example:  if a fiscal year starts from 30 November 2009 and ends at 28 november 2010.
    it should return 30 th nov 2009 (first day of the fiscal year)

    Moderator message - Welcome to SCN.
    I think you'll find that this question has been answered before. Please search the forum before posting.
    Also, Please read Please read "The Forum Rules of Engagement" before posting!  HOT NEWS!! and How to post code in SCN, and some things NOT to do... and [Asking Good Questions in the Forums to get Good Answers|/people/rob.burbank/blog/2010/05/12/asking-good-questions-in-the-forums-to-get-good-answers] before posting again.
    Rob

Maybe you are looking for