Finding Day from Date i.e. Monday, Tuesday etc

Hi,
I need to find out the day from Date. i.e. Monday, Tuesday etc. This is because if the date falls on Saturday or Sunday need to charge difference rates and on weekdays having normal rates.
Thanks,
Amol

We should probably add a function for this as I've certainly seen the requirement before.
Fortunately it's pretty easy to calculate using a simple rule - the trick is to pick a date in the past that was a Monday, and then use the modulo operator.
For example:
The day of the week = (the given date - 1980-01-07) modulo 7
ie the 7th of January 1980 was a Monday, so every 7th day after that is also a Monday - so combined with the modulo operator this will give you:
0 monday
1 tuesday
5 saturday
6 sunday
The only downside is that dates before 1980-01-07 will give a negative modulo (this is distinct from the mathematical modulo operator, but is necessary to be symmetric with the integer division operator truncating towards zero) - so dates before the baseline date will give:
0 monday
-6 tuesday
-2 saturday
-1 sunday
You can either choose to write the rules to take this into account, or choose a baseline date so far in the past that it's unnecessary.
Regards
Andrew

Similar Messages

  • How to find Days in date

    hi friends.
    I want to find out days in date.
    is there is any method or FM to find out days in date.
    thanks in advance.
    regards.
    Bhaskar.

    Hi,
    do like this.
    data:v_dat like sy-datum,
    v_daytext like HRVSCHED-DAYTXT,
    v_out(20) type c.
    v_dat = sy-datum.
    CALL FUNCTION 'RH_GET_DATE_DAYNAME'
      EXPORTING
        langu                     = sy-langu
        date                      = v_dat
      CALID                     =
    IMPORTING
      DAYNR                     =
       DAYTXT                    = v_daytext
      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.
    else.
    v_out = v_daytext.
    ENDIF.
    write:/ v_out.
    for more information go to se37 and check the function module.
    do reward points if it helps you.
    Regards,
    Sowjanya.

  • Subtract business days from date - calculated column

    Hello,
    I had a calculated column on a library that took two dates and found the difference between them in business days, but I am not sure how to subtract business days from a date...for instance I get a start date from a form and I need to
    subtract 10 business days from that date.
    Can anyone help?

    I've always resorted to Javascript/JQuery for that kind of function. I found an old fashioned loop worked the best for me - it supports going forward or backwards. I key it off of a change in a starting date, or sometimes a status change. My actual production
    code takes into account another list where we remove holidays and non-work days.
    newDate = getNextDate(newDate, -3);
    $("input[title='Date Due']").val((newDate.getMonth() + 1) + "/" + newDate.getDate() + "/" + newDate.getFullYear());
    function getNextDate(currentDate, offset) {
    // offset is business days
    var wkend = 0;
    var index = Math.abs(offset); // need positive number for looping
    var neg = true;
    if(offset >= 0) { neg = false; }
    var curDOW = currentDate.getDay();
    var nextDate = new Date(currentDate);
    for(var i=1; i <= index; i++) {
    nextDate.setDate(nextDate.getDate() + (neg ? -1: 1));
    var nextDOW = nextDate.getDay();
    if(nextDOW == 0) {nextDate.setDate(nextDate.getDate() + (neg ? -2: 1));} // Sunday
    if(nextDOW == 6) {nextDate.setDate(nextDate.getDate() + (neg ? -1: 2)); } // Sat
    // alert("offset is " + offset + "start: " + currentDate + ", next date is " + nextDate);
    return nextDate;
    Robin

  • Extrating day from date

    Hi All,
    Extracting day form sysdate is <?xdoxslt:sysdate(‘Day’)?>
    but i want to extract day from <?xdoxslt:ora_format_date_offset(xdoxslt:sysdate('YYYY-MM-DD'),1,'-')?> (sysdate-1 date's day)
    How can i ? any ideas pleae share me.
    Thanks

    DD is working fine
    <?xdoxslt:xdo_format_date($_XDOXSLTCTX,(xdoxslt:ora_format_date_offset(xdoxslt:sysdate('YYYY-MM-DD'),1,'-')),’DD’)?>
    Day and Dy is not working giving result like check boxes
    <?xdoxslt:xdo_format_date($_XDOXSLTCTX,(xdoxslt:ora_format_date_offset(xdoxslt:sysdate('YYYY-MM-DD'),1,'-')),’Day’)?>
    do i need to give any supporting format for xdo_format_date?

  • Need help finding accounts that expire 90 days from date created

    Hi, I am trying to find all temp accounts in AD that expire 90 days after the account was created.  Here is what I have so far. I am not sure how to calculate that. I am not receiving any output.
            $expireDate = (Get-ADUser -filter * -Properties accountExpires).accountExpires
        $accountExpireDate = ([System.DateTime]::FromFileTime($expireDate)).AddDays(-90).Date
        Get-ADUser -Filter {whenCreated -ge $accountExpireDate} -Properties whenCreated | select name | export-csv 'c:\temp\all_temp_users.csv'enter code here

    OK. I read your question again and I think I understand what you are asking now.
    Try it this way:
    $DaysSinceCreation = 90
    get-aduser -ldapfilter "(&(!(accountExpires=0))(!(accountExpires=9223372036854775807)))" -properties accountExpires,whenCreated | foreach-object {
    $accountExpires = [DateTime]::FromFileTime($_.accountExpires)
    if ( ($accountExpires - $_.whenCreated).Days -eq $DaysSinceCreation ) {
    new-object PSObject -property @{
    "distinguishedName" = $_.DistinguishedName
    "whenCreated" = $_.whenCreated
    "accountExpires" = $accountExpires
    -- Bill Stewart [Bill_Stewart]
    Here is what i modified for expand the range of $dayssincecreation value. It appears to work but is kind of sloppy. Its not a big deal, but is there a way to make this cleaner? i tried a range variable and did not have any luck. Again thanks for all your
    help!
    $DaysSinceCreation = 85
    $DaysSinceCreation1 = 86
    $DaysSinceCreation2 = 87
    $DaysSinceCreation3 = 88
    $DaysSinceCreation4 = 89
    $DaysSinceCreation5 = 90
    $DaysSinceCreation6 = 91
    $DaysSinceCreation7 = 92
    $DaysSinceCreation8 = 93
    $DaysSinceCreation9 = 94
    $DaysSinceCreation10 = 95
    $DaysSinceCreation11 = 96
    get-aduser -ldapfilter "(&(!(accountExpires=0))(!(accountExpires=9223372036854775807)))" -properties accountExpires,whenCreated | foreach-object {
    $accountExpires = [DateTime]::FromFileTime($_.accountExpires)
    if ( ($accountExpires - $_.whenCreated).Days -eq $DaysSinceCreation -or ($accountExpires - $_.whenCreated).Days -eq $DaysSinceCreation1 -or ($accountExpires - $_.whenCreated).Days -eq $DaysSinceCreation2 -or ($accountExpires - $_.whenCreated).Days -eq $DaysSinceCreation3 -or ($accountExpires - $_.whenCreated).Days -eq $DaysSinceCreation5 -or ($accountExpires - $_.whenCreated).Days -eq $DaysSinceCreation6 -or ($accountExpires - $_.whenCreated).Days -eq $DaysSinceCreation7 -or ($accountExpires - $_.whenCreated).Days -eq $DaysSinceCreation8 -or ($accountExpires - $_.whenCreated).Days -eq $DaysSinceCreation9 -or ($accountExpires - $_.whenCreated).Days -eq $DaysSinceCreation10 -or ($accountExpires - $_.whenCreated).Days -eq $DaysSinceCreation11) {
    new-object PSObject -property @{
    "SamAccountName" = $_.SamAccountName
    "whenCreated" = $_.whenCreated
    "accountExpires" = $accountExpires

  • Finding 'Day' via date

    Hello all,
    I have an ABAP task for which I have to find that the day behind the date is 'Sunday' or 'Saturday'.
    How can I do that? For example : today is 3.12.2007. How can i check via ABAP that today is saturday or not?
    Please respond.
    Regards,
    Aisha Ishrat
    ICI Pakistan Ltd.

    Hi,
    Use this code
    DATA : DATE like SCAL-DATE,
    DAY LIKE SCAL-INDICATOR.
    DATE = '20050728'.
    CALL FUNCTION 'DATE_COMPUTE_DAY'
    EXPORTING
    DATE = DATE
    IMPORTING
    DAY = DAY.
    CASE DAY.
    WHEN 1.
    WRITE :/ 'MONDAY'.
    WHEN 2.
    WRITE :/ 'TUESDAY'.
    WHEN 3.
    WRITE :/ 'WEDNESDAY'.
    WHEN 4.
    WRITE :/ 'THURSDAY'.
    WHEN 5.
    WRITE :/ 'FRIDAY'.
    WHEN 6.
    WRITE :/ 'SATURDAY'.
    WHEN 7.
    WRITE :/ 'SUNDAY'.
    ENDCASE.
    IF HELP FULL REWARD

  • Year , Month & Day from Date.

    Hi HANA experts,
      Do help me to resolve this issue
    How can we extract or fetch year from the date.i went through some of the SCN blogs.where they create calculation views...but the steps are not that clear to me.
    can anyone please explain??
    My scenario is :
    I have date field in ANALYTIC VIEW which i have fetched from ECC  tables.
    now i need to get  the year  wise month wise and day wise reports. so what steps i should do in calculation view to get that??
    thanks
    Neeraja

    there is no ECC under SAP...as we are using suite on HANA fro AWS.and there is no restriction done by the basis till now...
    as we are new to these unable to trouble shoot things easily.
    thanks for your reply..

  • Substracting number of days from date

    Hi all, I need to create a user exit to get a date value based on another variable. Basically, 100 days minus the first variable.
    var2 = var1 - 100
    How can I write this?
    Thanks.

    Ok, I figured it out. I had to declare variables of type d and then assign it.
    IF i_step = 2.
        data:zday type d,
              zday1 type d.
    *****Loops for Variable.*****************************************
        LOOP AT I_T_var_range
             INTO loc_var_range WHERE
                      VNAM = 'ZENDT' or
                      VNAM = 'ZENDATE'.
        zday = loc_var_range-low.
        zday1 = zday - 275.
    *      l_S_range-low = loc_var_range-low - 275.
          l_S_range-low = zday1.
          l_s_range-sign = 'I'.
          l_s_range-opt = 'EQ'.
          APPEND l_s_range TO E_T_range.
        ENDLOOP.
        EXIT.
      ENDIF.

  • Name of the day from date based on the logon language

    Hi All,
    Could anyone help me with any function module which gives the name of the day after entering the date. but the name of the day should be language specific. I know DATE_COMPUTE_DAY_ENHANCED gives the name of the day but this is in english. I want the name/ description based on the logon language.
    For example, I login in EN and I execute the above function module for date, 19.10.2010. so the weekday is Thursday. but this 'thursday' should be given in the logon language not the same even if I login in DE etc.
    Thanks a lot in advance!!
    Regards,
    Swathi

    Hi Swathi,
    You can try to use FM DATE_COMPUTE_DAY to get the day ID, and then consult table T246 or execute FM DAY_NAMES_GET to get the day description in the desired language.
    Kind regards,
    Garcia

  • Determine day from date

    Hi all,
    I would like to determine if the day is working day given a date. I want to exclude weekend and public holidays. Is there any FM which can give me that.
    Please help.
    Thanks
    Devang
    Edited by: Diksha Chopra on Dec 29, 2009 1:28 AM

    Hi
    Use this
    mport java.util.ArrayList;
    import java.util.Calendar;
    import java.util.Date;
    import java.util.List;
    public class WorkingDaysFinder {
        static List<Date>  holidayList =  new ArrayList<Date>();
        // holiday list
        static{
            holidayList.add(new Date("08/18/2009"));
            holidayList.add(new Date("08/19/2009"));
        public static void main(String args[]){
            Date day1 = new Date("08/17/2009"); // start date
            Date day2 = new Date("08/27/2009"); // end date
            Date dayCounter = day1;
            int counter = 1;
            while(dayCounter.before(day2)){
                // check for weekends and holiday list
                if(dayCounter.getDay() != Calendar.SATURDAY &&
                   dayCounter.getDay()!=Calendar.SUNDAY &&
                   !holidayList.contains(dayCounter))
                    counter++; // count weekdays
                dayCounter.setDate(dayCounter.getDate()+1);
            System.out.println("Working days = "+counter);
    Regards
    Monika

  • HT4796 cannot find files from data migration

    I have run the data migration utility and can see the user but files will not update.
    Jeff

    Look in /Users. If you ran Migration Assistant after the intial Setup Assistant, it tends to create a new user with your stuff in it.

  • Extract date from date

    Hi All,
    I have a query. I want to name of the day from the date selected from the record.
    I know there is a function Extract that extracts the day from the date. But it returns the day number of the month. I want to extract the name of the day i.e. wether it is 'Monday','Tuesday' etc.
    Is there any function that can do the above task.
    My complete requirement is to extract all emplid except those emplid from the record JOB where the eff_date is either 1 or 2 of the month and the date is Monday.
    Any help is appreciated.
    Regards,
    Amit

    Why not post your code, it will more easy to help you ?
    You're not so far from the solution with the query above...
    Anyway, try :
    select *
    from emp a
    where not exists (select 1
                      from emp b
                      where to_char(b.hiredate,'FMDay')='Monday'
                      and to_char(b.hiredate,'DD') in (1,2)
                      and a.empid=b.empid);Nicolas.

  • Yosemite iCal no longer prints Day with Date for 1 day printout.

    Previous to v10.10, when printing an iCal single day calendar (Monday, Tuesday, etc...) by default it would print (for example) Friday, October 10. Yosemite iCal now only prints: October 10, omitting the day of the week.
    Is there a way to get the day-of-the-week back?
    Thnx

    Thanks Rockedge but the preferences switch still leaves the DAY of the week missing before the MONTH and Numeric Date.
         The old way and now desired printout: Monday, October 27
         Now its just: October 27
    The hope is to return the MONDAY back in the print version...
    My sarcastic but working fix is the Print to PDF, edit add day of the week, print, throw away...
    I know there's a generation of programmers up at Apple who just can't conceive why someone would actually want to "Print" something, but there are...
    Many thanks for your suggestion though...

  • How do I find my iCloud data that Yosemite erased ?? Yosemite has resurrected an old Apple ID from the Me days. Everything is gone because of Yosemite

    How do I find all my data on ICloud. I downloaded Yosemite and it erased ALL of my data on the Cloud. It caused an Apple ID from Me to resurrect and has wreaked havoc on my devices. It even erased all my backup data on my Passport drive. The Passport drive shows all of my downloaded backups from 2011, but when you double clickon the various backup dates, they all show as empty. I was able to restore my music by downloading a 3rd party application, but my pictures are gone. I was having a conversation thisweekend and an eavesdropper said she has the EXACT same problem.

    An apple ID is nothing more than a "User ID"
    Actually, it is more than that. If you read the licensing agreements for any OS version or app obtained at the app store, it will become clear: the license for any app or OS obtained at the app store is not transferable. Hence it is tied to your Apple ID and will remain so - it cannot be removed.
    You are supposed to remove anything obtained at the app store from the computer before giving/selling it. Your father will also not be able to reinstall the OS if need be.
    Which OS version was on the Mac originally? You will need to use internet recovery (Command + Option + R) to erase your drive and then reinstall the original OS (if Lion or later). If it came with an install DVD, boot from that, erase the drive and reinstall. After that, your father can very easily download/update/reinstall any OS or app using his own Apple ID.

  • Getting Day from the date :

    Hi,
    I want to get the day(Monday ,tuesday.. like that) and the input parameter for that function is the date let say 02/14/2006.

    > Can you explain it more elobarately.Because the
    content i got from that link some what puzzling to me.
    I posted the link to that class at 13:26, you again posted a reply at 13:40. If my calculator is correct, you've spent about 14 minutes looking at that class and the examples from that page. I also wouldn't understand it in that time.
    Try the examples on the page, alter them, see what happens. Come back here with a specific question.
    Good luck.

Maybe you are looking for

  • Get current connection in Open Tools development(SDK)

    Hi, I'm developing an Open Tool(with the SDK) and I need to get the current connection(repository connection) to do some transactions. I didn't find a way of getting the current connection but some existing tools are doing it(OdiExportAllScen, OdiExp

  • Hyperlink in Stickies

    How do I create a hyperlink in Stickies? I use the stickies as a general repository of information and it is not very tidy to have whole URLs pasted in to them.

  • Is thread still active after main method exits?

    Hi All, Yesterday we were discussing. wether it is possible for a thread to be active even after the main method, from which it was spawned, exits. any comments?

  • Need to know how to provide access to it admins based on RBAC on a file server.

    Hi , I am not a having a good knowledge in file server so if anything is wrong please correct me . Level 3 admin : I just wanted my level 3 admins need to provide a full permission and to do a changes on all the files and folders. Level 2 admin : I j

  • K8055

    Hi, I am using the vellaman usb card k8055 to genrate digital i/o.I managed to find out an VI from their website that can be used to run the card and it works fine.I would like to extend this to use it in 4 cards at the same time,since my application