Add a Date column

I want to add a column to the end of a existing Table that has data in it. I need the column to contain DATE information and then after inserting the column I need to make all the rows values for that new added column to be in this format:
Month-Year there is no need for an exact Date format like: 01/01/2008 TIME, just MM/YYYY
I think this has worked for me in the past, but I am not sure about the DATE parts that I want and I am not sure how to insert say MARCH/2009 into all the rows, help would be appreciated, thanks!
alter Table Y775.TABLE
add
SPEND_GROUP DATE;
COMMIT;

Hi,
You're on the right track: ALTER TABLE is the way to add a column. You can find the syntax in the [SQL Language manual|http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/index.htm#A].
DATE columns always have days, hours, minutes and seconds. For this particular column, always use 1 for the day, and 00 for the hours, minutes and seconds. TRUNC (dt, 'MM') is an easy way to keep the year and month from dt, but set the other parts to '01 00:00:00', like you want. Add a CHECK constraint to make sure all the values you put into that column are like that:
CHECK (spend_group = TRUNC (spend_group, 'MM'))You don't have to display the parts of the DATE that you don't need.
For example:
TO_CHAR (spend_group, 'MM/YYYY')

Similar Messages

  • How to add one date column and charecter column

    hi all,
    i have 3 column start_date(date),end_date( date),duration (varchar2)
    i am trying to add start_time and duration like this
    end_date := to_char(start_time) + duration;
    but its showing value_error
    how to add one date column and charecter column.
    Thanks

    you need something that does:
    end_date (DATE) := start_date (DATE) + <number of
    days> (NUMBER)Not necessarily, because if the duration is just a string representation of a number then it will be implicitly converted to a number and not cause an error
    e.g.
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select to_date('01/07/2007','DD/MM/YYYY') as start_dt, '3' as duration_days from dual)
      2  -- END OF TEST DATA
      3  select start_dt + duration_days
      4* from t
    SQL> /
    START_DT+
    04-JUL-07

  • Add approve data column in sp

    i want to add approve date from approval table i tried but it not works
    sp
    ALTER procedure [dbo].[spdocuments]
    as
    SELECT dbo.DocumentInfo.DocID as DocumentID,
    dbo.DocumentInfo.DocName as DocumentName,
    dbo.DocumentInfo.UploadedDate as UploadedDate ,
    dbo.DocumentInfo.Uploadfile as FileUploaded,
    dbo.DocumentInfo.UploadedBy as UploadedBy,
    dbo.Department.DepType as Department,
    dbo.Approval.ApproveDate,
    dbo.ApproveType.ApproveType as Status
    FROM dbo.DocumentInfo inner JOIN
    dbo.ApproveType ON dbo.DocumentInfo.ApproveID = dbo.ApproveType.ApproveID inner JOIN
    dbo.Department ON dbo.DocumentInfo.DepID = dbo.Department.DepID left join
    dbo.Approval on dbo.Approval.ApproveID = dbo.Approval.ApproveDate
    this sp returns me approve date column null like this
    DocumentID DocumentName UploadedDate FileUploaded UploadedBy Department ApproveDate Status
    30 computer science 2013-12-25 18:31:26.420 dotnetcodes.docx noreen Computer Science NULL Pending
    31 manual hr 2013-12-26 12:16:54.830 The Business Memo.doc kulsoom Human Resource NULL Approve
    whereas in approval table and in this approvedate data exist
    SeqNO DocID ApproveID AppoveBy DesigID ApproveDate
    258 30 1 sundus 1 2013-12-25 18:34:47.347
    259 30 1 kaneez 2 2013-12-25 18:34:47.347
    260 31 1 wajihazeb 3 2013-12-26 12:17:37.150

    You only got half my query.  It starts with a ;.
    ;with maxApproval as
      select approveId, max(approvalDate) as approvalDate from Approval group by approveId
    SELECT    di.DocID as DocumentID,
    di.DocName as DocumentName,
    di.UploadedDate as UploadedDate ,
     di.Uploadfile as FileUploaded,
    di.UploadedBy as  UploadedBy,
        d.DepType as Department,
       coalesce(ma.ApproveDate, ''),
     at.ApproveType as Status
    FROM         dbo.DocumentInfo di inner JOIN
                          dbo.ApproveType at ON di.ApproveID = at.ApproveID
    inner JOIN
                          dbo.Department d ON di.DepID = d.DepID left
    join
                          maxApproval ma on at.ApproveID = ma.ApproveID;
    This is a CTE.  You can learn about them in my article on Code Project, here:
    http://www.codeproject.com/Articles/702691/SQL-Wizardry-Part-Three-Common-Table-Expressions-C
    As you can see, I also aliased all your tables, which makes my SQL more concise.  As I said, the aliases ( like the di. in di.DocId ) can be removed if that column name only exists in one of the tables you're selecting from.
    Christian Graus

  • DRQ: document date column vendor statement

    Hello!
    We request to implement to add "document date" column on "vendor statement" report.
    Now, even if it is "checked" in settings and it is visible on "supplier liabilities ageing" (screenshot z1)
    [z1|http://img130.imageshack.us/img130/2002/61227598.jpg]
    It is not visible on reportsand printings ("supplier statement report") screenshot zel3
    [zel3|http://img406.imageshack.us/img406/994/zel3.jpg]
    This issue is detailed described (with screenshots) under SAP support
    request nr 280783 
    I have created service request to SAP and i have received answer:
    "There is note no. 1260740 which explains how to get the document date in the printout of aging report in the layout "Detailed Receivable Ageing Report".
    Unfortunately, after checking this in the layout you asked called "statement report", I saw that it is not possible to see the document date there, and it is not possible to add this field in the layo ut as the report is hardcoded.
    So the customer can see this field when using the layout "Detailed Receivable Ageing Report", but if it is very important for the customer to see the document date in the "statement report" layout, pl ease kindly refer to SAP Note No.1028874 regards Missing Functionality."

    I sort of solved this problem myself.
    Apparently, OPCH table (AP Invoice) was not available in the drop-down menu.
    So, I selected the closest I can get: OJDT table (Journal Entry) and selected TaxDate - Document Date.
    It works now.

  • Performance Impact of Unique Constraint on a Date Column

    In a table I have a compound unique constraint which extends over 3 columns. As a part of functionality I need to add another DATE column to this unique constraint.
    I would like to know the performance implications of adding a DATE column to the unique constraint. Would the DATE column behave like another VARCHAR2 or NUMBER column, or would it degrade the performance significantly?
    Thanks
    Message was edited by:
    user627808

    What performance are you concerned about degrading? Inserts? Or queries? If you're talking about queries, what sort of access path are you concerned about?
    Are you concerned that merely changing the definition of the unique constraint would impact performance? Or are you worried that whatever functional change you are making would impact performance (i.e. if you are now retaining historical data in the table rather than just updating it)?
    Regardless of the performance impact, unique indexes (and unique constraints) need to be correct. If you need to allow duplicates on the 3 current columns with different dates, then you would need to change the unique constraint definition regardless of the performance impact. Fast and wrong generally isn't going to be preferrable to slow and right.
    Generally, though, there probably is no reason to be terribly concerned about performance here. Indexing a date is no different than indexing any other primitive data type.
    Justin

  • Ordinal date columns in the activity details area  ?

    Is it possible to add ordinal date columns in the activity details area of Priamvera P6?

    It is possible - I just have to do it, I will let you know after I do it how it goes...

  • I want to add image in column is it possible then how to add image in data base what data type we need to do

    I want to add image in column is it possible then how to add image in data base  what data type we need to give we required any casting  please show me one example
    jitendra

    Hi again,
    Several points that can help more:
    1. If you are working with Dot.Net, then I highly recommend read the first link that you got! This is nice and simple coding. Another option is this link which is even better in my opinion:
    http://www.dotnetgallery.com/kb/resource21-How-to-store-and-retrieve-images-from-SQL-server-database-using-aspnet.aspx
    2. As i mention above both link use the column's type image. There are several other option of working with Files. In most of my applications architecture I find that it is better to use a column which let us use any type of file and not an image column.
    In choosing the right column's type for your needs basically your fist question should be if if you want to store your data inside relational database environment or outside relational environment. It is a good idea to look for blogs on this issue. Next
    if you chose to store your data inside then you need to chose the right column type according to your server version. I highly recommend to look for blogs on the differences between those column's types: IMAGE, 
    Check those links:
    To BLOB or Not To BLOB: Large Object Storage in a Database or a Filesystem
    http://research.microsoft.com/apps/pubs/default.aspx?id=64525
    FILESTREAM feature of SQL Server 2008
    http://msdn.microsoft.com/library/hh461480
    FileTables feature of SQL Server 2012
    http://technet.microsoft.com/en-us/library/ff929144.aspx
    Compare Options for Storing Blobs (SQL Server)
    http://technet.microsoft.com/en-us/library/hh403405.aspx
    Binary Large Object (Blob) Data (SQL Server)
    http://technet.microsoft.com/en-us/library/bb895234.aspx
    Managing BLOBs using SQL Server FileStream via EF and WCF streaming
    * Very nice tutorial!
    http://petermeinl.wordpress.com/2012/02/20/managing-blobs-using-sql-server-filestream-via-ef-and-wcf-streaming/
    [Personal Site] [Blog] [Facebook]

  • How to add attributes in Data Column for automatic changes

    Hello everybody,
    Could you give me an advice?
    I have characteristic and attribute assigned to it.
    I want to make what when i change  characteristic(variable) its attribute in planning layout changes too. So in planning area window in <b>Characteristics Rels</b> tab i made "<i>Derivation, Combination Check and Proposal</i>" with main characteristic and its atribute. Everything works fine, but problem is, that attribute can be only in <b>Header</b> or in <b>Lead column</b>. 
    In planning layout i want to add what attribute in data column.
    Maybe where is other solutions?
    Thanks in advance
    Best Regards,
    Arunas

    Hy, Srini,
    Thanks for your response.
    There is a simple example, which describes the main principle of my solution:
    Characteristic DIVISION
    A
    B
    (filled with master data)
    Characteristic LEVEL
    1
    2
    (filled with master data)
    Characteristic NAME
    Ben
    John
    (filled with master data)
    char. LEVEL, NAME are attributes for char. DIVISION
    DIVISION with master data:
    Division  Level  Name
       A        1     Ben
       B        2     Jhon
    Planning Layout:
    In header section is char. DIVISION (variable)
    When I select DIVISION with value A, in layout values for attributes should be displayed automaticaly:
    DIVISION = A
    NAME
    LEVEL
    (Lead column)
    (Data column)
    Ben
    1
    I find solution to do it with Characteristic Rels, but i can't insert char. LEVEL into Data Column, it can be just
    in Lead Column.
    I don't know how to do it.  
    Could you suggest something?
    Best Regards,
    Arunas

  • How to add a new column to a existing table and add data to this column?

    I have a table with about 10 millions row and I want to add a new column to this table, then fill this new column with prepared data.
    How to do it ?
    Thank you

    Can I use insert statement to add the data to new-added column?No.
    07:19:37 oracle >create table test (x number);
    Table created.
    Elapsed: 00:00:03.05
    07:19:53 oracle >
    07:19:53 oracle >
    07:19:53 oracle >insert into test values (1);
    1 row created.
    Elapsed: 00:00:00.00
    07:20:01 oracle >insert into test values (2);
    1 row created.
    Elapsed: 00:00:00.00
    07:20:10 oracle >insert into test values (3);
    1 row created.
    Elapsed: 00:00:00.00
    07:20:12 oracle >
    07:20:13 oracle >commit;
    Commit complete.
    Elapsed: 00:00:00.00
    07:20:14 oracle >
    07:20:19 oracle >select * from test;
             X
             1
             2
             3
    Elapsed: 00:00:00.00
    07:20:22 oracle >
    07:20:36 oracle >alter table test add (y number);
    Table altered.
    Elapsed: 00:00:00.05
    07:20:41 oracle >
    07:20:41 oracle >
    07:20:41 oracle >
    07:20:41 oracle >select * from test;
             X          Y
             1
             2
             3
    Elapsed: 00:00:00.00
    07:20:43 oracle >
    07:20:44 oracle >
    07:20:44 oracle >update test set y=1;
    3 rows updated.
    Elapsed: 00:00:00.02
    07:20:52 oracle >commit;
    Commit complete.
    Elapsed: 00:00:00.00
    07:20:56 oracle >select * from test;
             X          Y
             1          1
             2          1
             3          1
    Elapsed: 00:00:00.00
    07:20:58 oracle >Anand

  • Edit/add XML data in BI Publisher

    Hi
    I have a java program that is generating an XML file that I am using as input for my BI publisher for PO report. However, I want to add some extra information(location addresses corresponding to location id) that is not there in the XML and I cannot edit the java program generating it. Is there any way I can do this in BI publisher? Can I edit/add XML data in BI publisher? This is really urgent and I appreciate any help.
    Thanks,
    Sharmila

    You have to edit the package which has the sql query,
    without fetching them in xml , you cannot display that.
    BIP will not help you to get that into report.
    The code which generates the XML data has to edited for sure..
    I guess, i helped one guy for similar requirement,
    i guess you are asking in the same report..
    the java program in turn calls the Pl/Sql package which generates the XML data and pass it to the Java Concurrent Program.
    The Pl/Sql package picks data from these views po_headers_xml, po_lines_xml, po_distribution_xml.
    you can also add the columns you want to be displayed in these views, and then change the template accordingly.

  • ADF Unable to filter / sort date column in table

    Hi,
    I am using JDeveloper 11.1.1.7.
    I have a read only table inside a panel collection. One of the columns in the table is a date field. I have filterable and sortable properties set to true for all columns. Filter and sort property works for all columns expect the date column. The filter and sort options is not even shown for the date field (shown below).
    <af:column headerText="#{bindings.ASRTCreateRequestVO1.hints.CreationDate.label}"
                                             id="c7" sortable="true" width="100"
                                             filterable="true">
                                    <af:outputText value="#{row.CreationDate}"
                                                   id="ot7">
                                      <af:convertDateTime pattern="#{bindings.ASRTCreateRequestVO1.hints.CreationDate.format}"/>
                                    </af:outputText>
                                  </af:column>
    Please let me know if I am missing anything here.
    Thanks,
    Ashwin

    Hi Ashwin,
    As mentioned by Timo, for me also the filtering is working as usual.
    But while browsing through the ADF UI Guide I came across with below note
    If you want to use a component other than an inputText component for your filter (for example, an inputDate component), then instead of setting filterVisible to true, you can add the needed component to the filter facet.
    To do so:
    1. In the Structure window, right-click the column to be filtered and choose Insert inside af:column > JSF Core > Filter facet.
    2. From the Component Palette, drag and drop a component into the facet.
    3. Set the value of the component to the corresponding attribute within the FilterableQueryDescriptor class created in Step 1(not above step but you can find it in pg:390). Note that the value must take into account the variable used for the row, for example:
    #{af:inputDate label="Select Date" id="name" value="row.filterCriteria.date"}.
    This is in the section: 12.5.1 How to Add Filtering to a Table(pg:390).
    I hope it helps.
    Regards,
    Peddi.

  • Date Column not getting sorted in a table in web Dynpro Java

    Hi All,
    I am facing an issue while sorting the date column in a table in my web dynpro java application.
    When the date is displayed in the sql format in tha table, I am able to sort the date column successfully but when we convert the date field from sql format to util format in our table and then sort it does not work.
    Kindly let us know the steps to be followed in this case to sort the date column of a table in Simple Date format as we do not want date in the sql format to be displayed.
    Thanks & Regards,
    Anurag

    Hi,
    You might want to check whether both your browser's language settings are identical. The browser language could also determine the date format.
    As a workaround, you could add an extra attribute to your context, and set the calculated property to 'true'.
    In your table, add a new column and bind to this new attribute, and hide your original date column
    If you sort using the date column that's hidden now, you could use the calculated field to fixed-format your date the way you prefer (by using the SimpleDateFormatter class for instance)
    Cheers,
    Robin

  • XML Publisher - Dynamic Data Columns Issue

    Hi,
    I am creating a amortization report where I need to show the amortization schedule for unearned revenue. Customers have signed different years of contract and I need to show the amount as per their remaining contract months. So if there are 2 month remaining in the contract then I should show the data for 2 months only and if there are 10 months then I should display 10 months. If we run the report for both customers then it should display two lines in report. For first customer the data should be only for 2 months and for second row(customer) there should be data for next 10 months. These months should be columns in the report(like excel columns, not rows). I need to display all months in columns instead of rows.
    I have acheived that using Dynamic Data Columns as mentioned in the user guide. Everything is working fine except following issues -
    1. How to create page level total?_
    I have created page total in my template using <?add-page-total:TOTUREV;'UREV'?> and displaying using <?show-page-total:TOTUREV?> but when I run the report in excel format these page total do not display. These columns are static columns not dynamic.
    If I run the report in pdf format then the static column total is displayed correctly.
    2. When I run the report in excel format then report run fine and it shows all the columns properly but if I run the report in pdf format then the dynamic column are not displayed in their own columns, all the columns are overwriting each other in a single columns itself, its not expanding.
    3. How do I get the total for the dynamic columns?_
    I need to display the page level total for the dynamic columns also, how do I do that?
    4. When I run the report in excel format the 2 decimal places of the numbers are gone(it works fine in pdf output), like 12.50 becomes 12.5 and 14.00 becomes 14. I need to maintain those 2 decimal places. I have tried using <fo:bidi-override direction="ltr" unicode-bidi="bidi-override"><?format-number:CVALUE;'999999D99'?></fo:bidi-override> but this does not solve my problem completely. It shows the values correctly in excel but then I am not able to do any calculation on those columns, looks like it converts them to text values.
    Any help is really appreicated. Please let me know if you need the xml template and data file.
    Regards
    Hitesh

    Hi Hitesh,
    Can you please upload your RTF and XML template file? I will try to spend sometime on this issue.
    Cheers
    Sachin

  • How can I add a new column in compress partition table.

    I have a compress partition table when I add a new column in that table it give me an error "ORA-22856: CANNOT ADD COLUMNS TO OBJECT TABLES". I had cretaed a table in this clause. How can I add a new column in compress partition table.
    CREATE TABLE Employee
    Empno Number,
    Tr_Date Date
    COMPRESS PARTITION BY RANGE (Tr_Date)
    PARTITION FIRST Values LESS THAN (To_Date('01-JUL-2006','DD-MON-YYYY')),
    PARTITION JUNK Values LESS THAN (MAXVALUE));
    Note :
    When I create table with this clause it will allow me to add a column.
    CREATE TABLE Employee
    Empno Number,
    Tr_Date Date
    PARTITION BY RANGE (Tr_Date)
    PARTITION FIRST Values LESS THAN (To_Date('01-JUL-2006','DD-MON-YYYY')),
    PARTITION JUNK Values LESS THAN (MAXVALUE));
    But for this I have to drop and recreate the table and I dont want this becaue my table is in online state i cannot take a risk. Please give me best solution.

    Hi Fahed,
    I guess, you are using Oracle 9i Database Release 9.2.0.2 and the Table which you need to alter is in OLTP environment where data is usually inserted using regular inserts. As a result, these tables generally do not get much benefit from using table compression. Table compression works best on read-only tables that are loaded once but read many times. Tables used in data warehousing applications, for example, are great candidates for table compression.
    Reference : http://www.oracle.com/technology/oramag/oracle/04-mar/o24tech_data.html
    Topic : When to Use Table Compression
    Bug
    Reference : http://dba.ipbhost.com/lofiversion/index.php/t147.html
    BUG:<2421054>
    Affects: RDBMS (9-A0)
    NB: FIXED
    Abstract: ENH: Allow ALTER TABLE to ADD/DROP columns for tables using COMPRESS feature
    Details:
    This is an enhancement to allow "ALTER TABLE" to ADD/DROP
    columns for tables using the COMPRESS feature.
    In 9i errors are reported for ADD/DROP but the text may
    be misleading:
    eg:
    ADD column fails with "ORA-22856: cannot add columns to object tables"
    DROP column fails with "ORA-12996: cannot drop system-generated virtual column"
    Note that a table which was previously marked as compress which has
    now been altered to NOCOMPRESS also signals such errors as the
    underlying table could still contain COMPRESS format datablocks.
    As of 10i ADD/SET UNUSED is allowed provided the ADD has no default value.
    Best Regards,
    Muhammad Waseem Haroon
    [email protected]

  • How to add a new columns in table contorl in standard screen.

    Hi All,
    I am working on a enhancement for transaction VA01. I have to add few column for tab Additional Data B. In this tab  column are displayed in table control. Now i have to add two more column in table control. Could you please help me to find out the exit and the way to populate the new columns.
    Thanks
    Piyush Mathur

    Hi Piyush,
              That table control might have been created using an internal table i.e declared in the exit. Add two more fields which you want to that internal table. And come to the layout and create table control once again using that internal table.
    Reward if helpful.
    Regards,
    Ramana

Maybe you are looking for

  • OfficeJet 6500 Wireless E709n - faulty yellow cartridge sensor - How do I print black only?

    Product is 5 years old.  Error message states that the Yellow Cartridge appears to be missing.  Unable to resolve following multiple Sensor and Sensor Window cleanings. Powered off/on several times including pulling plug. Attempted one new Yellow Car

  • Moving Aperture to an Intel Mac

    l originally downloaded the Aperture 2 trial and subsequently purchased the program again as a download. Now I am using an Intel MacPro and was wondering what would be the best procedure of getting Aperture 2 onto my newer machine.

  • Organism: extensible outliner+personal organizer (needs beta testers)

    Organism is basically a simple outliner structured in a very modular way: the core is written in Python 2 (but should be easily adaptable to Python 3) and provides the backend for interacting with sqlite databases, where the data is stored. The core

  • Import CR xml into PS?

    Hello Can I import or otherwise interpret adjustments made in Camera Raw and saved as .xml and use them in Photoshop? The reason I need to use PS for the adjustment step is that the imagery I'm trying to correct contains more than RGB data. While a C

  • Dynamic table page not passing ID parameter

    I have a page with a simple dynamic table: http://www.lenoxweb.net/idea/test10.php. BUt it does not show the data in the dynamic table. I have attached a record set to the page,and have it set for 10 records at a time (there are three records in the