Return year, quarter, month and week from a date

I use this to convert a date filed to year_week, year_month, year_quarter and year.
But when I use it in views I got problem with queries, they take long time...
Is this the best way to do this?
Select  to_char(rec_date, 'yyyy') || to_char(rec_date, 'IW') As year_week,
        to_char(rec_date, 'yyyy') || to_char(rec_date, 'mm') As year_month,
        to_char(rec_date, 'yyyy') || '0' || to_char(rec_date, 'q') As year_quarter,
        to_char(rec_date, 'yyyy') As year
FROM tbltest

I use this to convert a date filed to year_week, year_month, year_quarter and year.
But when I use it in views I got problem with queries, they take long time...
Is this the best way to do this?There is a big difference in showing a date in a certain format (year, month, quater, whatever) and restrict a selection to a certain date.
My guess is that you try to use the view with something like
SELECT * FROM myView
WHERE year = '2007' and year_month = '07'In this case the view is not able to transport the restriction (month='07') to the underlying column rec_date in your table tbltest.
The workaround is to directly use the date column and stay with a date value on it.
Like
SELECT * FROM myView
WHERE rec_date >= to_date('01072007','dd.mm.yyyy') and
and rec_date < to_date('01082007','dd.mm.yyyy') andA normal index on the column rec_date can be used in this second case. There is also a workaround for the first case useing function based indexes.

Similar Messages

  • Return the end of week date using month and week number

    Hi all,
    I am trying to find the date for end of the week using given month (201401, 201402...i.e, 2014 is year and 01,02 are months) and week number (01,02,03...) for the year. For example if my month is 201402 and week_number is 06 then it return the week_date
    as 2014-02-08. Can you please help me in writing a sql statement for this scenario.
    Thanks in advance,
    Nikhil

    Current month is irrelevant
    with dt as (
       select dateadd(day, (6-1)*7, '2014-01-01') as xwk
    select dateadd(day, 7-datepart(weekday, dt.xwk), xwk)
    from dt;
    Change the "6" in the with statement to the week of interest and 2014 to the year of interest...

  • How to get current fiscal year/quarter/month/week

    Post Author: [email protected]
    CA Forum: Semantic Layer and Data Connectivity
    Hi friends,
    I have to calculate
    1. current year/quarter/month/week.
    2.Previous year/quarter/month/week.
    please tell the process to achieve the above scenerio's.
    the structure of the fiscal_cal is as  follows.
    Name                                      Null?    Type
    TODAY                                     NOT NULL DATE
    FISCAL_DAY                                         NUMBER(8)
    FISCAL_WEEK                                        NUMBER(6)
    FISCAL_MONTH                                       NUMBER(6)
    FISCAL_QTR                                         CHAR(18)
    FISCAL_YEAR                                        NUMBER(4)
    FISCAL_MONTH_WORK_DAYS                             NUMBER(2)
    sample week data is as follows
    FISCAL_WEEK
         200752
         200753
         209901
    Thanks.

    based on ur target database DBMS you can find a built-in functions be used in the universe designer to get the requirment you talked about, like in oracle
    to_char(mydate,'yyyy') it will return the year in the yyyy format.
    and the same way for the other things you want
    to_char(mydate,'q') return the quarter.
    w return the week of the month
    ww return the week of the year
    mm return the month
    ,, to get the last year
    you can use also a builtin functions
    like add_months(mydate,-12) that return the same date for the last year, and you can do the same operations as before.
    its all related to the DBMS.
    good luck

  • Any F.Module is there to get  'Month and day '  from the given input number

    Hi experts,
        I am working on Inventory withdrawl report and in the selection screen, If i enter the CHARG (Batch number) then  I need to display the posting date by default in the next selection input based on the Batch number.
    In the selection screen :
    Batch : 7111WF0211.
    Posting Date :  (I need to display by default based on batch number).
    My requirement is,  in the above Batch first digit '7' is the year.
    And  from 2nd to 4th digit. i.e., 111. I need to find out month and day from 111.
    I mean from  1 to 365 days, In which day and which month '111' will come ?
    Please send me the code or suitable Function Module. Your help will be appreciated.
    Thanks,
    Ranji.

    Use FM ADD_TIME_TO_DATE
    Do this
    days = batch+1(3).
    days = days - 1.
    Call Function 'ADD_TIME_TO_DATE'
    exporting
    i_idate = '01.01.2008'
    i_time = days
    i_iprkz = 'D'
    importing
    o_idate = date_p_d
    You will get the date in date_p_d.
    But what about Leap years? IS the first number the year?
    IF so pass in i_idate the first of january of that year so you get the correct day depending if it is a leap year or not
    Edited by: Ramiro Escamilla on Feb 26, 2008 9:56 PM

  • HT201250 Is there a way to change the intervals at which Time Machine performs backups (e.g., weekly instead of hourly or daily) past 24 hours, daily for the past month, and weekly for everything older...

    Is there a way to change the intervals at which Time Machine performs backups (e.g., weekly instead of hourly or daily) past 24 hours, daily for the past month, and weekly for everything older...

    You can edit the interval in Console or install a Pref Pane
    called TimeMachineScheduler (Leopard or higher) free from:
    http://www.klieme.com/TimeMachineScheduler.html
    Good luck, Tom

  • Handling Time Dimensions with Monthly and Weekly analysis

    I'm charged to build a cube that can handle both monthly and weekly analysis. They want to be view projections on a weekly grain, but looking back at history they want to be able to tie back to the general ledger at a monthly level.
    Is it overkill to load data down to the daily level in order to support multiple roll ups to the month and week? What is the best way to handle this kind of situation?

    Having the data come as two different formats (one for months, one for weeks) versus having it come in daily buckets and constructing the months/weeks within Essbase is a call I wouldn't make without understanding the needs first.
    Assuming there is no need for data at the daily level, I would weigh the selection based on performace. If the performance is not too outragious, taking the data in at a daily basis would make it easier to reconstruct later. If performance is an issue (or becomes an issue), I would still be tempted to load a daily cube at level 0, summarize the Months and Weeks, and then feed the main cube from there.
    So many ways to do this... and for every way there is a reason you might want to try something else. I'd start with the easy approach, and only go "grand" if you have to (meaning: load it daily, summarize in Essbase, and revisit the detail/summary cube split idea if the performance tanks out).

  • To find months and days between 2 dates

    Hi,
    I want to find the months and days between 2 dates.
    For Eg.
    Date-1 : 25-Aug-2013
    Date-2 : 23-Oct-2013
    If we consider every month as 30 days it should give
    25-Aug-2013 to 30-Aug-2013 = 6 days
    01-Sep-2013 to 30-Sep-2013 = 1 Month
    23-Oct-2013 to 30-Oct-2013 =   8 days
    Total = 1 month and 14 days.
    Kindly help at the earliest.
    Thanks & Regards
    Suresh

    SureshM wrote:
    Hi,
    I want to find the months and days between 2 dates.
    For Eg.
    Date-1 : 25-Aug-2013
    Date-2 : 23-Oct-2013
    If we consider every month as 30 days it should give
    25-Aug-2013 to 30-Aug-2013 = 6 days
    01-Sep-2013 to 30-Sep-2013 = 1 Month
    23-Oct-2013 to 30-Oct-2013 =   8 days
    Total = 1 month and 14 days.
    Kindly help at the earliest.
    Thanks & Regards
    Suresh
    That's not a good idea though.  Be considering every month as 30 days, then comparisons over larger date ranges (years) will be out by more and more days the larger the difference gets.
    Your example is also wrong.
    For Eg.
    Date-1 : 25-Aug-2013
    Date-2 : 23-Oct-2013
    If we consider every month as 30 days it should give
    25-Aug-2013 to 30-Aug-2013 = 6 days
    01-Sep-2013 to 30-Sep-2013 = 1 Month
    23-Oct-2013 to 30-Oct-2013 =   8 days
    The last one should be:
    01-Oct-2013 to 23-Oct-2013 = 23 days
    giving a result of 1 month and 29 days.
    Oracle provides a months_between function to do the calculation.
    SQL> select months_between(date '2013-10-23', date '2013-08-25') from dual;
    MONTHS_BETWEEN(DATE'2013-10-23',DATE'2013-08-25')
                                           1.93548387
    But of course, because the number of days in a month varies, it's not exacly known what the decimal part of the number represents.
    However, if you combine methods, using months_between to get the months, and then assume 30 days for a month to get the days part from the remainder, it's more consistent over longer periods...
    SQL> ed
    Wrote file afiedt.buf
      1  with dates as (select date '2013-08-25' as date_from, date '2013-10-23' as date_to from dual)
      2  --
      3  select months_between(date_to, date_from)
      4        ,trunc(months_between(date_to, date_from)) as months
      5        ,round(mod(months_between(date_to, date_from),1)*30) as days
      6* from dates
    SQL> /
    MONTHS_BETWEEN(DATE_TO,DATE_FROM)     MONTHS       DAYS
                           1.93548387          1         28

  • Problem with ArrayLists and writing and reading from a .dat file (I think)

    I'm brand new to this forum, but I'm sure hoping someone can help me with a problem I'm having with ArrayLists. This program was originally created with an array of objects that were displayed on a GUI with jtextFields, then cycling thru them via jButtons: First, Next, Previous, Last. Now I need to add the ability to modify, delete and add records. Both iterations of this program needed to write to and read from a .dat file.
    It worked just like it was suppose to when I used just the array, but now I need to use a "dynamic array" that will grow or shrink as needed: i.e. an ArrayList.
    When I aded the ArrayList I had the ArrayList use toArray() to fill my original array so I could continue to use all the methods I'd created for using with my array. Now I'm getting a nullPointerException every time I try to run my program, which means somewhere I'm NOT filling my array ???? But, I'm writing just fine to my .dat file, which is confusing me to no end!
    It's a long program, and I apologize for the length, but here it is. There are also 2 class files, a parent and 1 child below Inventory6. This was written in NetBeans IDE 5.5.1.
    Thank you in advance for any help anyone can give me!
    LabyBC
    package my.Inventory6;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.Insets;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.text.DecimalFormat;
    import javax.swing.JOptionPane;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTextField;
    import java.io.*;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.lang.IllegalStateException;
    import java.util.NoSuchElementException;
    import java.util.ArrayList;
    import java.text.NumberFormat;
    // Class Inventory6
    public class Inventory6 extends javax.swing.JFrame {
    private static InventoryPlusColor[] inventory;
    private static ArrayList inList;
    // create a tool that insure the specified format for a double number, when displayed
    private DecimalFormat doubleFormat = new DecimalFormat( "0.00" );
    private DecimalFormat singleFormat = new DecimalFormat( "0");
    // the index within the array of products of the current displayed product
    private int currentProductIndex;
    /** Creates new form Inventory6 */
    public Inventory6() {
    initComponents();
    currentProductIndex = 0;
    } // end Inventory6()
    private static InventoryPlusColor[] getInventory() {
    ArrayList<InventoryPlusColor> inList = new ArrayList<InventoryPlusColor>();
    inList.add(new InventoryPlusColor(1, "Couch", 3, 1250.00, "Blue"));
    inList.add(new InventoryPlusColor(2, "Recliner", 10, 525.00, "Green"));
    inList.add(new InventoryPlusColor(3, "Chair", 6, 125.00, "Mahogany"));
    inList.add(new InventoryPlusColor(4, "Pedestal Table", 2, 4598.00, "Oak"));
    inList.add(new InventoryPlusColor(5, "Sleeper Sofa", 4, 850.00, "Yellow"));
    inList.add(new InventoryPlusColor(6, "Rocking Chair", 2, 459.00, "Tweed"));
    inList.add(new InventoryPlusColor(7, "Couch", 4, 990.00, "Red"));
    inList.add(new InventoryPlusColor(8, "Chair", 12, 54.00, "Pine"));
    inList.add(new InventoryPlusColor(9, "Ottoman", 3, 110.00, "Black"));
    inList.add(new InventoryPlusColor(10, "Chest of Drawers", 5, 598.00, "White"));
    for (int j = 0; j < inList.size(); j++)
    System.out.println(inList);
    InventoryPlusColor[] inventory = (InventoryPlusColor[]) inList.toArray
    (new InventoryPlusColor[inList.size()]);
    return inventory;
    } // end getInventory() method
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents() {
    jPanel1 = new javax.swing.JPanel();
    IDNumberLbl = new javax.swing.JLabel();
    IDNumberField = new javax.swing.JTextField();
    prodNameLbl = new javax.swing.JLabel();
    prodNameField = new javax.swing.JTextField();
    colorLbl = new javax.swing.JLabel();
    colorField = new javax.swing.JTextField();
    unitsInStockLbl = new javax.swing.JLabel();
    unitsInStockField = new javax.swing.JTextField();
    unitPriceLbl = new javax.swing.JLabel();
    unitPriceField = new javax.swing.JTextField();
    invenValueLbl = new javax.swing.JLabel();
    invenValueField = new javax.swing.JTextField();
    restockingFeeLbl = new javax.swing.JLabel();
    restockingFeeField = new javax.swing.JTextField();
    jbtFirst = new javax.swing.JButton();
    jbtNext = new javax.swing.JButton();
    jbtPrevious = new javax.swing.JButton();
    jbtLast = new javax.swing.JButton();
    jbtAdd = new javax.swing.JButton();
    jbtDelete = new javax.swing.JButton();
    jbtModify = new javax.swing.JButton();
    jbtSave = new javax.swing.JButton();
    jPanel2 = new javax.swing.JPanel();
    searchIDNumLbl = new javax.swing.JLabel();
    searchIDNumbField = new javax.swing.JTextField();
    jbtSearch = new javax.swing.JButton();
    searchResults = new javax.swing.JLabel();
    jbtExit = new javax.swing.JButton();
    jbtExitwoSave = new javax.swing.JButton();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Inventory Program"));
    IDNumberLbl.setText("ID Number");
    IDNumberField.setEditable(false);
    prodNameLbl.setText("Product Name");
    prodNameField.setEditable(false);
    colorLbl.setText("Product Color");
    colorField.setEditable(false);
    colorField.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    colorFieldActionPerformed(evt);
    unitsInStockLbl.setText("Units In Stock");
    unitsInStockField.setEditable(false);
    unitPriceLbl.setText("Unit Price $");
    unitPriceField.setEditable(false);
    invenValueLbl.setText("Inventory Value $");
    invenValueField.setEditable(false);
    restockingFeeLbl.setText("5% Restocking Fee $");
    restockingFeeField.setEditable(false);
    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
    jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addContainerGap()
    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
    .addComponent(unitPriceLbl)
    .addComponent(unitsInStockLbl)
    .addComponent(colorLbl)
    .addComponent(prodNameLbl)
    .addComponent(IDNumberLbl)
    .addComponent(restockingFeeLbl)
    .addComponent(invenValueLbl))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
    .addComponent(IDNumberField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)
    .addComponent(prodNameField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)
    .addComponent(colorField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)
    .addComponent(unitsInStockField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)
    .addComponent(unitPriceField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)
    .addComponent(restockingFeeField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)
    .addComponent(invenValueField, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE))
    .addContainerGap())
    jPanel1Layout.setVerticalGroup(
    jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addContainerGap()
    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(IDNumberLbl)
    .addComponent(IDNumberField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(prodNameLbl)
    .addComponent(prodNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(colorField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(colorLbl))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(unitsInStockField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(unitsInStockLbl))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(unitPriceField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(unitPriceLbl))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(restockingFeeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(restockingFeeLbl))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(invenValueField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(invenValueLbl))
    .addContainerGap())
    jbtFirst.setText("First");
    jbtFirst.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jbtFirstActionPerformed(evt);
    jbtNext.setText("Next");
    jbtNext.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jbtNextActionPerformed(evt);
    jbtPrevious.setText("Previous");
    jbtPrevious.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jbtPreviousActionPerformed(evt);
    jbtLast.setText("Last");
    jbtLast.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jbtLastActionPerformed(evt);
    jbtAdd.setText("Add");
    jbtAdd.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jbtAddActionPerformed(evt);
    jbtDelete.setText("Delete");
    jbtModify.setText("Modify");
    jbtModify.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jbtModifyActionPerformed(evt);
    jbtSave.setText("Save");
    jbtSave.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jbtSaveActionPerformed(evt);
    jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Search by:"));
    searchIDNumLbl.setText("Item Number:");
    jbtSearch.setText("Search");
    searchResults.setFont(new java.awt.Font("Tahoma", 1, 12));
    javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(
    jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel2Layout.createSequentialGroup()
    .addContainerGap()
    .addComponent(searchIDNumLbl)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel2Layout.createSequentialGroup()
    .addGap(259, 259, 259)
    .addComponent(searchResults, javax.swing.GroupLayout.PREFERRED_SIZE, 213, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
    .addComponent(jbtSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(searchIDNumbField, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)))
    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    jPanel2Layout.setVerticalGroup(
    jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel2Layout.createSequentialGroup()
    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(searchIDNumLbl)
    .addComponent(searchIDNumbField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel2Layout.createSequentialGroup()
    .addGap(32, 32, 32)
    .addComponent(searchResults, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGroup(jPanel2Layout.createSequentialGroup()
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(jbtSearch)))
    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    jbtExit.setText("Save and Exit");
    jbtExit.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jbtExitActionPerformed(evt);
    jbtExitwoSave.setText("Exit");
    jbtExitwoSave.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jbtExitwoSaveActionPerformed(evt);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 248, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 44, Short.MAX_VALUE)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
    .addComponent(jbtExitwoSave, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addComponent(jbtExit)))
    .addGroup(layout.createSequentialGroup()
    .addComponent(jbtFirst)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(jbtNext)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(jbtPrevious)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(jbtLast))
    .addGroup(layout.createSequentialGroup()
    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addGap(12, 12, 12)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
    .addComponent(jbtAdd)
    .addComponent(jbtDelete)
    .addComponent(jbtModify)
    .addComponent(jbtSave))))
    .addContainerGap())
    layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jbtFirst, jbtLast, jbtNext, jbtPrevious});
    layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jbtAdd, jbtDelete, jbtModify, jbtSave});
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(21, 21, 21)
    .addComponent(jbtAdd)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(jbtDelete)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(jbtModify)
    .addGap(39, 39, 39)
    .addComponent(jbtSave))
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(jbtFirst)
    .addComponent(jbtNext)
    .addComponent(jbtPrevious)
    .addComponent(jbtLast))
    .addGap(15, 15, 15)
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGroup(layout.createSequentialGroup()
    .addComponent(jbtExit)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(jbtExitwoSave)))
    .addContainerGap())
    pack();
    }// </editor-fold>
    private void jbtExitwoSaveActionPerformed(java.awt.event.ActionEvent evt) {                                             
    System.exit(0);
    private void jbtSaveActionPerformed(java.awt.event.ActionEvent evt) {                                       
    String prodNameMod, colorMod;
    double unitsInStockMod, unitPriceMod;
    int idNumMod;
    idNumMod = Integer.parseInt(IDNumberField.getText());
    prodNameMod = prodNameField.getText();
    unitsInStockMod = Double.parseDouble(unitsInStockField.getText());
    unitPriceMod = Double.parseDouble(unitPriceField.getText());
    colorMod = colorField.getText();
    if(currentProductIndex == inventory.length) {
    inList.add(new InventoryPlusColor(idNumMod, prodNameMod,
    unitsInStockMod, unitPriceMod, colorMod));
    InventoryPlusColor[] inventory = (InventoryPlusColor[]) inList.toArray
    (new InventoryPlusColor[inList.size()]);
    } else {
    inventory[currentProductIndex].setIDNumber(idNumMod);
    inventory[currentProductIndex].setProdName(prodNameMod);
    inventory[currentProductIndex].setUnitsInStock(unitsInStockMod);
    inventory[currentProductIndex].setUnitPrice(unitPriceMod);
    inventory[currentProductIndex].setColor(colorMod);
    displayProduct(inventory[currentProductIndex]);
    private static void writeInventory(InventoryPlusColor i,
    DataOutputStream out) {
    try {
    out.writeInt(i.getIDNumber());
    out.writeUTF(i.getProdName());
    out.writeDouble(i.getUnitsInStock());
    out.writeDouble(i.getUnitPrice());
    out.writeUTF(i.getColor());
    } catch (IOException e) {
    JOptionPane.showMessageDialog(null, "I/O Exception writing data",
    "", JOptionPane.ERROR_MESSAGE);
    System.exit(0);
    } //end writeInventory()
    private static DataOutputStream openOutputStream(String name) {
    DataOutputStream out = null;
    try {
    File file = new File(name);
    out =
    new DataOutputStream(
    new BufferedOutputStream(
    new FileOutputStream(file)));
    } catch (IOException e) {
    JOptionPane.showMessageDialog(null, "I/O Error", "", JOptionPane.ERROR_MESSAGE);
    System.exit(0);
    return out;
    } // end openOutputStream()
    private static void closeFile(DataOutputStream out) {
    try {
    out.close();
    } catch (IOException e) {
    JOptionPane.showMessageDialog(null, "I/O Exception closing file",
    "", JOptionPane.ERROR_MESSAGE);
    System.exit(0);
    } // end closeFile()
    private static DataInputStream getStream(String name) {
    DataInputStream in = null;
    try {
    File file = new File(name);
    in = new DataInputStream(
    new BufferedInputStream(
    new FileInputStream(file)));
    } catch (FileNotFoundException e) {
    JOptionPane.showMessageDialog(null, "The file doesn't exist",
    "", JOptionPane.ERROR_MESSAGE);
    System.exit(0);
    } catch (IOException e) {
    JOptionPane.showMessageDialog(null, "I/O Error creating file",
    "", JOptionPane.ERROR_MESSAGE);
    System.exit(0);
    return in;
    private static void closeInputFile(DataInputStream in) {
    try {
    in.close();
    } catch (IOException e) {
    JOptionPane.showMessageDialog(null, "I/O Exception closing file",
    "", JOptionPane.ERROR_MESSAGE);
    System.exit(0);
    } // end closeInputFile()
    private double entireInventory() {
    // a temporary double variable that the method will return ...
    // after each product's inventory is added to it
    double entireInventory = 0;
    // loop to control number of products
    for (int index = 0; index < inventory.length; index++) {
    // add each inventory to the entire inventory
    entireInventory += inventory[index].setInventoryValue();
    } // end loop to control number of products
    return entireInventory;
    } // end method entireInventory
    private void jbtLastActionPerformed(java.awt.event.ActionEvent evt) {                                       
    currentProductIndex = inventory.length-1; // move to the last product
    // display the information for the last product
    displayProduct(inventory[currentProductIndex]);
    private void jbtPreviousActionPerformed(java.awt.event.ActionEvent evt) {                                           
    if (currentProductIndex != 0) // it's not the first product displayed
    currentProductIndex -- ; // move to the previous product (decrement the current index)
    } else // the first product is displayed
    currentProductIndex = inventory.length-1; // move to the last product
    // after the current product index is set, display the information for that product
    displayProduct(inventory[currentProductIndex]);
    private void jbtNextActionPerformed(java.awt.event.ActionEvent evt) {                                       
    if (currentProductIndex != inventory.length-1) // it's not the last product displayed
    currentProductIndex ++ ; // move to the next product (increment the current index)
    } else // the last product is displayed
    currentProductIndex = 0; // move to the first product
    // after the current product index is set, display the information for that product
    displayProduct(inventory[currentProductIndex]);
    private void jbtFirstActionPerformed(java.awt.event.ActionEvent evt) {                                        
    currentProductIndex = 0;
    // display the information for the first product
    displayProduct(inventory[currentProductIndex]);
    private void colorFieldActionPerformed(java.awt.event.ActionEvent evt) {                                          
    // TODO add your handling code here:
    private void jbtModifyActionPerformed(java.awt.event.ActionEvent evt) {                                         
    prodNameField.setEditable(true);
    prodNameField.setFocusable(true);
    unitsInStockField.setEditable(true);
    unitPriceField.setEditable(true);
    private void jbtAddActionPerformed(java.awt.event.ActionEvent evt) {                                      
    IDNumberField.setText("");
    IDNumberField.setEditable(true);
    prodNameField.setText("");
    prodNameField.setEditable(true);
    colorField.setText("");
    colorField.setEditable(true);
    unitsInStockField.setText("");
    unitsInStockField.setEditable(true);
    unitPriceField.setText("");
    unitPriceField.setEditable(true);
    restockingFeeField.setText("");
    invenValueField.setText("");
    currentProductIndex = inventory.length;
    private void jbtExitActionPerformed(java.awt.event.ActionEvent evt) {                                       
    DataOutputStream out = openOutputStream("inventory.dat");
    for (InventoryPlusColor i : inventory)
    writeInventory(i, out);
    closeFile(out);
    System.exit(0);
    private static InventoryPlusColor readProduct(DataInputStream in) {
    int idNum = 0;
    String prodName = "";
    double inStock = 0.0;
    double pric

    BalusC -- The line that gives me my NullPointerException is when I call the "DisplayProduct()" method. Its a dumb question, but with NetBeans how do I find out which reference could be null? I'm not very familiar with how NetBeans works with finding out how to debug. Any help you can give me would be greatly appreciated.The IDE is com-plete-ly irrelevant. It's all about the source code.
    Do you understand anyway when and why a NullPointerException is been thrown? It is a subclass of RuntimeException and those kind of exceptions are very trival and generally indicate an design/logic/thinking fault in your code.
    SomeObject someObject = null; // The someObject reference is null.
    someObject.doSomething(); // Invoking a reference which is null would throw NPE.

  • FM to calculate date month & year six months previous to the current date

    Hi All,
    Is there any function module or code to calculate date month & year six months previous to the current date.
    Thanks in advance.

    hi,
    try this
      data : date1 like vbak-erdat.
    data : q type numc3.
    selection-screen : begin of block blk2 with frame title text-001.
    parameters : n like q.
    selection-screen : end of block blk2.
    if n > 0.
    CALL FUNCTION 'CCM_GO_BACK_MONTHS'
             EXPORTING
               CURRDATE         = sy-datum
               BACKMONTHS       = n
           IMPORTING
              NEWDATE          = date1
    selection-screen: begin of block blk1 with frame title text-001.
    select-options :  s_date for vbak-erdat default 'NEWDATE'  to 'sy-datum' no-display.
    selection-screen : end of block blk1.
    write : date1.
    Reward with points if helpful.

  • Calculate gross profit, yearly sales,monthly sales,weekly sales?

    hi all
    i try to create procedures according to these conditions 
    What are my yearly sales?
    What are my monthly sales?
    What are my weekly sales?
    What are my daily sales?
    What is my Gross Profit?
    What is my Gross Sales?
    this is star schema
    now how i calculate yearly sales, monthly sales, and also gross profit.
    create procedure spgrossprofit
    as
    select as grossprofit from dimfact
    now which aggregate function i use for calculate above conditions?
    any help?

    Sorry(ETC) is a Spanish expression = the same for the next option
    The correct query:
    Year/Month
    create procedure spyearlysales
    as
    select sum(totalsales),Year(Dimtime.date) from Dimtime
    inner join Dimfact on Dimtime.Time_Key=dimfact.Time_Key
    group by Year(Dimtime.date)create procedure spmonthsales
    as
    select sum(totalsales),year(Dimtime.date),Dimtime.Month from Dimtime
    inner join Dimfact on Dimtime.Time_Key=dimfact.Time_Key
    group by Year(Dimtime.date),Dimtime.Month
    JM Claudio Dba/Consultor SQL/BI Pasiona - Spain

  • ATP: Monthly and Weekly are overlapping

    Hi Friends,
    I want to start and stop on some specific dates in every month.
    I am having a requirement in which weekly and monthly availabilty planning are overlapping. One channel has to be closed on last day of  every month and start on 8th of every month. But all other days it should work also, ie, every week also.
    So, what needs to be done. Right now one weekly plan is working. But if i create month end rule also, it's unable to recognize that.
    Please suggest.
    Regards,
    Nutan

    Since your requirement to start and stop channels are not consistent every day or week, YOu might want to think about writing script to control the channels externally. The below is the sample comand to start channels where action = start or stop.
    In unix or linux environment use wget followed by http or https url link as below.
    wget http(s)://host:port/AdapterFramework/ChannelAdminServlet?party=party&service=service&channel=channel&action=start
    Hope that helps.

  • Function module to retrieve day of the week from a date.

    Hi Experts,
    i am looking for a function module to retrieve the day of the week from a specific date. For example, the date is 20070820. The day of this date is 'Monday'.
    Please let me know how do i get the result i.e. 'Monday'.
    thanks a lot for ur timely help.
    Best regards,
    Aksh

    DATE_COMPUTE_DAY
         Returns a number indicating what day of the week the date falls on. Monday is returned as a 1, Tuesday as 2, etc.
    DATE_IN_FUTURE
         Returns a number indicating what day of the week the date falls on. Monday is returned as a 1, Tuesday as 2, etc.
    DAY_ATTRIBUTES_GET
         Return useful information about a day. Will tell you the day of the week as a word (Tuesday), the day of the week (2 would be Tuedsay), whether the day is a holiday, and more
    regards,
    srinivas

  • Find first & last day of the week from given date

    Hi All,
    I have the below input query,
    WITH TEM AS   ( SELECT '11-JAN-13' DT from dual union   SELECT '16-JUN-12' from dual union   SELECT '04-JUL-12' from dual union   SELECT '09-JAN-13' from dual union   SELECT '10-JAN-13' from dual union   SELECT '04-JAN-13' from dual union   SELECT '07-JAN-13' from dual union   SELECT '04-JUN-13' from dual union   SELECT '08-JAN-13' from dual )  SELECT TO_DATE(DT) D1,'WEEK '||TO_CHAR(TO_DATE(DT),'IW-YYYY') WK from tem;
    I would like to get the below output i.e. Starting date of the week(Saturday) & end date of the week(Friday)
    DT
    WEEK Period
    Max Date in this week
    Min Date in this week
    16-Jun-12
    WEEK 24-2012
    16-Jun-12
    22-Jun-12
    04-Jul-12
    WEEK 27-2012
    30-Jun-12
    06-Jul-12
    04-Jan-13
    WEEK 01-2013
    04-Jan-13
    29-Dec-12
    07-Jan-13
    WEEK 02-2013
    05-Jan-13
    11-Jan-13
    08-Jan-13
    WEEK 02-2013
    05-Jan-13
    11-Jan-13
    09-Jan-13
    WEEK 02-2013
    05-Jan-13
    11-Jan-13
    10-Jan-13
    WEEK 02-2013
    05-Jan-13
    11-Jan-13
    11-Jan-13
    WEEK 02-2013
    05-Jan-13
    11-Jan-13
    04-Jun-13
    WEEK 23-2013
    01-Jun-13
    07-Jun-13
    Also suggest if any function available in oracle for this one.

    Like this? I think in your required output, 3rd row data, MAX_DATE should be 29-DEC-12 and MIN_DATE should be 04-JAN-13.
    WITH TEM AS 
    ( SELECT '11-JAN-13' DT from dual union 
    SELECT '16-JUN-12' from dual union
    SELECT '04-JUL-12' from dual union
    SELECT '09-JAN-13' from dual union
    SELECT '10-JAN-13' from dual union 
    SELECT '04-JAN-13' from dual union
    SELECT '07-JAN-13' from dual union
    SELECT '04-JUN-13' from dual union
    SELECT '08-JAN-13' from dual )
    SELECT D1 DT,
           WK WEEK_PERIOD,
           CASE WHEN (TRIM(TO_CHAR(D1,'DAY'))='SATURDAY') THEN D1
                 ELSE NEXT_DAY(D1,'SATURDAY')-7
            END AS MAX_DATE_IN_THIS_WEEK,
          CASE WHEN (TRIM(TO_CHAR(D1,'DAY'))='FRIDAY') THEN D1
                ELSE NEXT_DAY(D1,'FRIDAY') END AS MIN_DATE_IN_THIS_WEEK
    FROM (
    SELECT TO_DATE(DT) D1,'WEEK '||TO_CHAR(TO_DATE(DT),'IW-YYYY') WK from tem)
    ORDER BY DT;
    OUTPUT:
    DT        WEEK_PERIOD  MAX_DATE_ MIN_DATE_
    16-JUN-12 WEEK 24-2012 16-JUN-12 22-JUN-12
    04-JUL-12 WEEK 27-2012 30-JUN-12 06-JUL-12
    04-JAN-13 WEEK 01-2013 29-DEC-12 04-JAN-13
    07-JAN-13 WEEK 02-2013 05-JAN-13 11-JAN-13
    08-JAN-13 WEEK 02-2013 05-JAN-13 11-JAN-13
    09-JAN-13 WEEK 02-2013 05-JAN-13 11-JAN-13
    10-JAN-13 WEEK 02-2013 05-JAN-13 11-JAN-13
    11-JAN-13 WEEK 02-2013 05-JAN-13 11-JAN-13
    04-JUN-13 WEEK 23-2013 01-JUN-13 07-JUN-13
    9 rows selected.

  • I can't drag and drop from a data CD I recorded

    I recently burned some audiobooks files (in mp3 format) as data cd's in Toast 8.0.1. When I go to reload them back onto my 20" 2 Ghz Dual Core Intel I can't drag and drop the files directly into any folder while using the columns view in a finder window. I can do it if I drag onto the music folder and let it spring open down to the level of the folder. I also can drag the mp3's into iTunes and then into the folder. This is not CD related since I used several diff brands.
    I constantly update, backup, repair permissions, and do other maintenance so everything is up to date. I have noticed this behavior just since I started to use the program called Audiobook Builder. I am (and have always used) a non-admin user account. When this started a few months ago it seemed to go away with a restart, permission repair, or a logout but now it seems permanant. I checked user permissions on my home folder - I have not added any software since adding Audiobook Builder. Any idea's? I read something about trashing a com.apple pref but didn't try that.
    I suspect Audiobook Builder since it changes the permissions and filetype to the iTunes Audiobook filetype but have not seen anyone reference this.
    wes

    dj_paige wrote:
    While the programming of course could be done, the idea of a function that performs on original unprocessed images seems to violate the whole idea of what Lightroom was designed to be. At least that's my opinion. Of course, the idea that Adobe should do this programming for a relatively small number of people (you're one of a very few people to ask for this, that I have read) seems to be something that isn't going to happen.
    I agree, I can't see much reason for drag-and-drop to drag the unprocessed image - in other words, an image that isn't the one that you see when you drag and drop.  I can see that just filling this forum with "why the heck does it do that????????" posts.  I could be wrong, but I suspect that Adobe won't do that. 
    But if you do want to drag-and-drop the original unprocessed image, you can do it very easily now.  Right click the image, choose "show in Explorer", and then drag-and-drop from Explorer. 

  • BI Routnie in DTP to calculate current week from current date

    Hello Team
    I want to write routinue to calculate current week based on date
    For eg, this week is
    201410, so the routine will get 201410 based on today’s date 4 Mar 2014.
    Can any1 please help
    Regards,
    Ankit

    I had written following code its giving error like
    E:Field "/BI0/9AVERSION" is unknown. It is neither in one of the
    specified tables nor defined by a "DATA" statement. "DATA" statement.
      data: l_idx like sy-tabix.
      read table l_t_range with key
           fieldname = '/BI0/9AVERSION '.
      l_idx = sy-tabix.
    Data: Date Like scal-date.
    Data: week like scal-week.
    call function 'DATE_GET_WEEK'
    exporting
    date = sy-datum
    importing
    week = SOURCE_FIELDS-/BI0/9AVERSION
    exceptions
    date_invalid = 1
    others = 2.
    * Return code <> 0 means skip whole data package !!!
    returncode = 0.

Maybe you are looking for

  • How can we import Fixed asset of the current year ?

    Hi , in 1272578 note , SAP Support explain that's it's not possible to create fixed asset of the current year( example = acquisition date = 2009-02-01 )  using import , but they gave no workaround . does it mean that we have to manually create all as

  • Update a filed value with powershell script with ordery by and where condition

    Hi I have below powershell script to update list columns but  how i update a field value with ordery by a column and where condition below is the part of my script $list = $web.Lists[$listName] $items = $list.items $internal_counter = 1 #Go through a

  • Tax license by region

    Hello people! I really need your help in this one: we are going to implement SAP in a company settled in Canada. The users requested us that it is highly important to maintain Tax exemption certificate for GST (GST is "Goods and sales tax" -- not wit

  • JTree - with two tree Models

    I have two types of tree Models that I would like to combine into one tree i did the combination this way: public CombainedTreeModel(BaseTreeModel firstSubTree,BaseTreeModel secondSubTree) { super(null); BaseTreeNode root=new BaseTreeNode("root"); in

  • Photoshop 10.8.1 et Mac OS 10.6

    Bonjour, Pourriez-vous me dire si Photoshop 10.8.1 (qui tourne actuellement avec Mac OS 10.5.8)  fonctionne avec Mac OS 10.6 et 10.7? Merci.