Week, month, quarter and year calculation between two days with a quantity?

I have a problem that I can't solve.

Users enter a forecast (quantity) and a validity period between two dates.
Expected quantity is always a monthly forecast.

The problem is that the user wants to see the forecast by week, month, quarter and year.


Material |     Quantity |     Date_from | Date_to
Label45 |     1500 |     2009-09-01 | 2009-12-31


How can I easily calculate the amount so that the user can enter e.g. week 2009.41 and see the forecast this week?

You should test for your specific environment, but I would be very surprised if a function has surpassed SQL directly.

Tags: Database

Similar Questions

  • Function to create dates as well as the week, quarter, and year

    Hi all

    I am trying to write a function that will create automatically with their respective week, quarter, and year dates in different columns.

    For example,.

    Date of the quarter Qtr/Yr/QtrWk week exercise exercise exercise

    415 Q4-WK1352201530/09/2015

    I would like to create a full year for each day of show week quarter Qtr/year/QtrWk, exercise, exercise from 01/10/2015-09 30, 2016.

    Appreciate your help and advice.

    Thank you

    AMan

    Hi AMan,

    can't answer your question with a detailed requirement.

    No doubt a whole year can be created in a SQL statement (CONNECT BY or the recursive subquery factoring) and is not a problem.

    But I would like to ask you the following:

    • How do you get the week number? There might be a different way to look at it (ISO or not, week starting with the Sun, Mon or the first day of the year, etc.)
    • The same question can be applied to the financial week. When it's the first week? 01/10/2015 until 10/07/2015?

    You can have a quick glance at the definition of different week in 'Model of Format of Date' on this page:

    https://docs.Oracle.com/CD/B28359_01/server.111/b28286/sql_elements004.htm

    Check the difference between WW and IW.

    Kind regards.

    Alberto

  • vMotion between two hosts with different version?


    Hello

    Can I vMotion VM between two hosts with different version? For example, a virtual machine of esxi 6.0 5.5 esxi and esxi esxi 6.0 5.5 vMotion.

    Thank you.

    Yes, it will avoid you to move.

  • vMotion (without shared storage) between two hosts with different vSwitches standard s VM

    I can VM vMotion (without shared storage) between two hosts with different vSwitches standard? The vSwitches on these two hosts have different names and number of NIC, but have the same name of portgroup.


    Thank you.

    Yes, you can in a Storage VMotion to one Esxi to another with no shared storage...

    It is important the portgroup bears the same name... This is the reference for the VM...

  • I did an installation 22.00 per month plan and can not install Photoshop, only with the lightroom

    I did an installation 22.00 per month plan and can not install Photoshop, only with the lightroom

    Hi Alex % 20arc,.

    You can troubleshoot Adobe Creative cloud download, install and update questions and we invite you to update the discussion in the case where you need help with this.

    Thank you

  • Because between two keyframes with the same position, there is movement?

    Because between two keyframes with the same position, there is movement?

    This would be due to the influence or speed?

    Quick glance:

    1. image: 'x' is 384px

    Capturar.PNG

    2 image: 'x' is 387px

    Capturar_2.PNG

    3. picture: 'x' is 384px

    Capturar_3.PNG

    Keyframes to which I refer are selected in the middle.

    Photo.PNG

    There is a change in the balance between two key frames that are in the same position, without keyframes between them.

    FAQ: Why my layer (camera) moves backward between the keyframes value equal?

  • Calculations between two time fields

    Hello

    I have a form with a time for the start time field and a text field for the user to enter a duration (for example, 00:30:00).

    There is another field for the end of time (which has a calculation script using the date and starting time fields).

    The script that was placed in the end time field works except the script gives a negative result.

    For example the start time field is 16:03:33 and 00:30:00 duration field calculation end is showing time field-

    Please can someone advise how I can change the script of the time field end to show the correct result of 16:33 (without the negative)?


    create string for the current date
    var oToday = new Date();
    sToday var = util.printd ("yyyy/mm/dd", oToday);

    get the value of the start time field

    var sStart = this.getField("Action_Start_Time").value;

    create the JavaScript date object time for start time
    var start = util.scand ("yyyy/mm/dd hh: mm:", sToday + sStart);


    get the duration value

    Send var = this.getField("Action_Time").value;

    create a JavaScript date object time to end time
    oEnd var = util.scand ("yyyy/mm/dd hh: mm", sToday + shipment);

    calculate the difference in hours, the difference in hours
    var DiffHours = (oEnd.valueOf () - oStart.valueOf (()) / 1000 / 60 / 60;
    Event.Value = Math.floor (DiffHours) + ': ' + util.printf ("%,302.0f", (((DiffHours % 1) * 60) .toFixed (()));

    Any help will be greatly appreciated.

    You cannot change the '-' operator operator '+' being Modulo calculation date and time calculations. You must calculate the different parts of the date and time of the start time and elapsed time and then convert these values into a date object time and format of this new date time object.

    Clear the field
    Event.Value = "";
    getting the activity start time
    var sEventStart = this.getField("Activity_Start_Time").value;
    calculate only if there is a start time
    If (sEventStart! = "") {}
    operations of the console are for debugging and illustration
    /*
    Console.Show ();
    Console.clear();
    */
    convert a date object change if necessary format
    var oEventStart = util.scand ("YYYY, mm, DD, HH", nNowYear + "," + (nNowMonth + 1) + ',' + nNowDate + ', ' + sEventStart);
    Console.println ("oEventStart:" + oEventStart);

    get the date current time
    var oNow = new Date();
    Console.println ("oNow:" + oNow);
    get the date parts
    var nNowYear = oNow.getFullYear ();
    var nNowMonth = oNow.getMonth ();
    var nNowDate = oNow.getDate ();
    /*
    Console.println ("nNowYear:" + nNowYear);
    Console.println ("nNowMonth:" + nNowMonth);
    Console.println ("nNowDate:" + nNowDate);
    */
    get the duration of activity
    var sEventDuration = this.getField('Event_Duration').value;
    If no entry in force at time zero
    if(sEventDuration == '') sEventDuration = "00:00:00 ';
    convert the time in hours and minutes
    var aEventDuration = sEventDuration.split(":");
    /*
    Console.println (' hours - aEventDuration [0]: "+ aEventDuration [0]");
    Console.println ('Minutes - aEventDuration [1]: "+ aEventDuration [1]");
    Console.println (' hours start: "+ oEventStart.getHours ());
    Console.println ("minutes:" + oEventStart.getMinutes ());
    Console.println ("second Start:" + oEventStart.getSeconds ());
    */
    calculate the minutes and the end times
    var nEndHour = Number (oEventStart.getHours ()) + Number(aEventDuration[0]);
    var nEndMinute = Number (oEventStart.getMinutes ()) + Number(aEventDuration[1]);
    if(aEventDuration.Length == 3)
    var nEndSecond = Number (oEventStart.getSeconds ()) + Number(aEventDuration[2]);
    on the other
    var nEndSecond = Number (oEventStart.getSeconds () + 0;
    /*
    Console.println ("nEndHour:" + nEndHour);
    Console.println ("nEndMinute:" + nEndMinute);
    Console.println ("nEndSecond:" + nEndSecond);
    Console.println ("nNowYear:" + nNowYear);
    Console.println ("nNowMonth:" + nNowMonth);
    Console.println ("nNowDate:" + nNowDate);
    */
    do the date for the end of the event object - calculate the hours and minutes
    oEnd var = new Date (nNowYear, nNowMonth, nNowDate, nEndHour, nEndMinute, nEndSecond);
    Console.println ('oEnd: ' + oEnd);
    change the format if necessary
    Event.Value = util.printd ("HH", oEnd);
    } / / end of event time

  • Can I use Lightroom CC between two Macs with different versions of the operating system

    I have the CC for photographers. I keep my work to Dropbox LR catalog and access them from my MacBook Air laptop or my desktop iMac computer. Currently, two computers are running the same version of Mac OS. I think to upgrade the laptop for the new OS of Sierra, but because the office is older, I thought maybe not upgrade (it is near the minimum end of systems that can run Sierra). Can someone tell me if there is a conflict with the help of the LR catalog between two computers if they are not both running the same version of Mac OS. When the catalog is saved in the operating system that you are starting, it would still be compatible for use on the computer with the previous version of Mac OS? Thank you! Barbara

    If the machines use the same version of the software, then the files should be feasible in both machines.

  • Replication between two sites with essential Kit more

    Hi all

    can anyone confirm that the following scenario is possible?

    A basic Kit Plus - replication - another essential Kit Plus
    3 Hosts                                                                      Other 3 Hosts

    In other words: is it possible to replicate virtual machines between two sites, each managed by a single essential Kit Plus (outside the bounds of the CV)?

    I'm sure that is correct, but I want to be sure.

    Thank you guys!

    Alex

    Yes, you can use replication between vCenters thus vSphere. To do that you would like to devices VR is deployed to each vCenter and then connect them. How to do this is described in the VR installation and config and administrative documents.

    BTW, my name is GS.

    See you soon!

  • Synchronization between two databases with only 2% of the data; Please help me

    Hi all

    I have two oracle databases in 2 different servers PROD and TEST instances. the two databases are in gr 10 2 in linux servers.

    My PROD database contains about 300 GB of data and is dedicated for production area.
    My Test database is dedicated to Spanish test for PROD database. (small server in terms of space and RAM comparing to PROD db)
    I would like to synchronize every week TEST db with PROD db with only 2% of the data and all the structures
    Could someone tell me, if you use a datapump export I can import only 2% of the amount of data and the structures ot theere is another way to do it?
    Thank you very much

    best regards,
    W

    I'm not really sure what you're talking about. There is no option, expdp and impdp x % of the data, is that? And if Oracle can sovle repositories inetegrity (PK, FK), it cannot be assumed which tables are lookup table (to be entirely exported) and can not assume the logical data integrity.

    Nicolas.

  • I bought Lenovo G550, 6 months before and now I m is problem with key product of Windows because of the striped top, so please tell me how it would be possible to get this product key

    I bought Lenovo G550, 6 months before and now I got problems with my PC and have problem with the Windows product key due to scratch on it, so please tell me how it would be possible to get this product key.

    Behind my laptop, here is a sticker mentioned
    Proof of license
    Certificate of authenticity
    Microsoft
    Microsoft Corporation @2005
    X 15-53803
    and on the bar code is mentioned after the number.
    00.94 - 893-397-158
    Product key. M... 62-8GX88-69-... - f7b

    Hello BHASKARPIYA,

    Product Key Finder programs, if someone advises to use, is found only on your operating system preinstalled a Levono multiple factory facilities and will be of no use in these circumstances.

    You will need to contact Lenovo and request their assistance.

    Or a way around this is to buy a Lenovo recovery DVD to reinstall the operating system or use the built-in recovery Partition containing an image of your OS and reinstall Windows like that.

    No method requires a product key to be entered by you.

  • calculations between two values of the sequential loop iterations

    Hi all

    I have a code that came out our power (DSP) of a FFT spectral density. An input frequency and then intervened at a value of input from the user. I would like to know the difference of the PSD between each stage of the frequency. Attached, that's what I would get. To avoid confusion, I don't want to produce a file that looks like this. I want just the column 'delta' as an indicator on the front panel, so I can control my change in PSD. I don't need the entire table, just the delta between the current iteration and the previous iteration. I tried to use a loop with shift registers, but I'm not sure where to go to from there. I thought that, since the shift registers sends the data of loop to loop, that I could output the value before it went into the next iteration, but I don't have a chance. Any help is appreciated. Unfortunately, I am unable to put the code due to the policy of the company. I know it makes things much more difficult.

    Thank you.

    Suggestions do not seem quite right, but I found a way to do it. Attached, is the way that I did.

  • Forward and meet vmail between two servers of the unit?

    I have a network with where two unity servers are connected and they are able to vmail prior to each other. (I did it using information from a document in a previous post

    ( http://www.cisco.com/en/US/products/sw/voicesw/ps2237/products_installation_and_configuration_guide_book09186a00801ba396.html ) However, when this is done, it is not an option to meet the vmail in vmail transmitted within the same server of the unit. Is it possible to configure it to respond? In other words, can you set up to meet the vmail passed the way you can when a vmail is routed within the same server Unity? Is it still possible? I don't see it in the document. The unity server is 4.03 with out-of-box Exchange. The other is 3.1.6 with a box on Exchange unit. Each is in a different domain. Thank you.

    No, there isn't a way around him. Putting servers in the same forest requires a reinstallation of the unit. You can use DiRT to help you do it, but this isn't something that we document step by step, because this isn't a normal activity. The only real challenge you may have there naming. As the dirt trying to match the name in SQL with the directory during a restoration, if you have any overlap, you may have some problems. I had read the help file for dirt to get a better idea about the process of migration:

    http://www.ciscounitytools.com/helpfiles/UnityDisasterRecovery.htm

    Thank you

    Keith

  • How to get the time in hours minutes and seconds subtraction between two varchar t

    Hi all

    I have two variable varchar that has a value like this

    v_outpunch1: = 17: 50:00'
    and v_Shifttime: = 18:00:00 '


    This time I'm subtracting here and in another varchar variable
    who's like that.



    v_EarlyLeaverstimeformat: = ((extrait extrait de (heure de TO_TIMESTAMP (v_ShiftTime, 'HH24:mi:ss'))-(heure de TO_TIMESTAMP (v_OutPunch1, 'HH24:mi:ss') LPAD)), 2, '0'): ': ' |)) LPAD ((extrait (minute de TO_TIMESTAMP (v_ShiftTime, 'HH24:mi:ss'))-extrait (minute de TO_TIMESTAMP (v_OutPunch1, 'HH24:mi:ss'))), 2, '0'): ': ' |)) LPAD ((extrait (seconde de TO_TIMESTAMP (v_ShiftTime, 'HH24:mi:ss'))-extrait (seconde de TO_TIMESTAMP (v_OutPunch1, 'HH24:mi:ss'))), 2, '0');))



    It is not properly subtracting value.

    Thank you

    This works for me...

    SQL> ed
    Wrote file afiedt.buf
    
      1  with t as(select to_date('17:50:00','HH24:MI:SS') as out, to_date('18:00:00','HH24:MI:SS') as shft from dual)
      2  --
      3  select to_char(trunc(sysdate)+(shft-out),'HH24:MI:SS') as diff
      4* from t
    SQL> /
    
    DIFF
    --------
    00:10:00
    

    If you want something different, please report the details according to the FAQ: {message identifier: = 9360002}

  • How can I make the difference of position (X 2 - X 1) and (y1 - y2) between two (2) separate cursor?

    Como posso fazer uma are difference (X 2 - X 1) e (y2 - y1) between doi (2) different cursor? Veja uma imagem com o erro: nao APB. Muito obrigado. Juscelino.

    You could do something like the following.

Maybe you are looking for

  • Location of the file music

    Hello, I've recently added a few albums in iTunes.  After you add the I noticed that iTunes them stored in a different location that all my my previous adds. (It has been a while since I added anything).  I'm curious to know why this happened, but I'

  • How to remove a user name from the logon screen?

    Hi all I have an annoying problem and do not know how to solve. What happened is that used to use my laptop for the log-in het Skype account my ex-girlfriend. But in the login screen continues to display his name as mine always does. I used different

  • Pavilion dv6 3190sp: CODE to STOP BIOS password

    Help, please! I never needed to put a bios password and suddenly he asked for it, "System disabled" with a code below: 75596040.  What can I do?  Thanks in advance!

  • Audio examples and vibration - activate or not?

    Hello I am a student and I use the evaluation version of LV I am playing with audio examples and vibrations, but I don't see the block diagram only the façade. It says to activate LV. Need to activate the OAS tool to see examples block diagram or is

  • MEU pc esta sem audo

    MEU pc esta sem audo