I want to caluculate expiration date column

CREATE TABLE test_table
EXPIRESON TIMESTAMP (3),
lastrun TIMESTAMP (3),
STARTDATE varchar2(35),
TITLE VARCHAR2 (60 BYTE),
ENDreportAFTER NUMBER (10),
NOOFRUNS NUMBER (10),
RUNONSUNDAY NUMBER (1),
RUNONMONDAY NUMBER (1),
RUNONTUESDAY NUMBER (1),
RUNONWEDNESDAY NUMBER (1),
RUNONTHURSDAY NUMBER (1),
RUNONFRIDAY NUMBER (1),
RUNONSATURDAY NUMBER (1)
insert into test_table
('','7/7/2011 8:30:15.00 am','7/7/2011 8:30:15.00 am' ,'weekly',2,1,0,0,0,0,1,1,0);
On 7th my data should looks like :
expirationdate should be :7/8/2011 8:30:15.00 am( if my noofruns is 1 that means my report success on 7/7 at 8:30)
expirationdate should be :7/14/2011 8:30:15.00 am( if my noofruns is null that means my report failed on 7/7 at 8:30)
On 8th my data should looks like :
expirationdate should be :7/14/2011 8:30:15.00 am(if my noofruns is 1 that means my report failed on 7/8 at 8:30)
expirationdate should be :7/15/2011 8:30:15.00 am(if my noofruns is 0 that means my report failed on 7/8 at 8:30)
On 14th my data should looks like :
expirationdate should be :7/15/2011 8:30:15.00 am(if my noofruns is 1 that means my report failed on 7/8 at 8:30)
expirationdate should be :7/21/2011 8:30:15.00 am(if my noofruns is 0 that means my report failed on 7/8 at 8:30)
can any one help me
Thanks in advance

If you are using Oracle 11g, consider typing your "expiration date" column as a virtual column. It would make sense to do so as the expiration date is based on logic between the other columns as opposed to being its own "real" independent value.
For a little more on virtural columns:
http://wiki.oracle.com/page/Virtual+Columns
CREATE TABLE test_table
EXPIRESON TIMESTAMP (3) generated always as (--expression here--) virtual,
lastrun TIMESTAMP (3),
RUNONSATURDAY NUMBER (1)
);The Oracle docs have the exact syntax and its options so that you can customize its definition to your needs.
When you populate or update the table, skip the virtual column and let the database take over the calculation from there. The value in a virtual column is not stored anywhere. It is derived at the time the table is queried. This usually shows with very large tables when a developer queries "select * from table..."; the tradeoff is saved disk space for "redundant" values for extra cpu cycles to calculate the derived value. Check a few references to see the tradeoffs and decide if it will work for your situation...
RP

Similar Messages

  • SCD type 2 Dimension default expiration date

    I am using OWB 10.2.0.2.8 and exploring the SCD handling for dimensions.
    I have setup a simple dimension with a single level (no hierarchy) using the Wizard, set the SCD property to type 2 and chosen the Trigger History attributes.
    When I now use the dimension in a mapping (basic population from a base table), I want to set the effective date and expiration dates. I am calling a custom function to derive the effective date = current business date and want set the expiration date to a function based value (a system high date rather than NULL).
    The dimension properties in the mapping allow a value to be entered (e.g. TO_DATE('31-dec-9999','DD-MON-YYYY') but not a function call. I am getting the following validation error:
    "VLD-5011: Dimension RISK_CLASS_DIM: The Default Expiration Date of closed records for dimension RISK_CLASS_DIM should be an expression of type DATE.
    Value PKG_CONSTANTS.EFFECTIVE_HIGH_DATE is not a valid date: PLS-00201: identifier PKG_CONSTANTS.EFFECTIVE_HIGH_DATE must be declared"
    Any suggestions?

    the current flag could be set in a Derived Column with an expression like: RowEffectiveDt < GETDATE() && RowExpirationDt >= GETDATE() ? "Y" : "N"
    http://msdn.microsoft.com/en-us/library/ms141680.aspx ? : operator
    http://msdn.microsoft.com/en-us/library/ms139875.aspx
     GETDATE()
    Please mark the post as answered if it answers your question | My SSIS Blog:
    http://microsoft-ssis.blogspot.com |
    Twitter

  • Updating a variable based on checking expiration date against now() in each row of a table

    I’m using Coldfusion 9,0,0,251028 on Windows 7 64-bit, with a Microsoft Access 97 database.
    I’m trying to create a query which loops through all the rows in a table and checks if the current date is later or earlier than the expiration date. 
    If the expiration date column is earlier than now(), it sets the column “is_current” to 0, which is a variable that controls whether or not a message displays on a different page(breakingnews.cfm). 
    The column that has the expiration date is “exp_dat” in the table “news”. The query I have so far is:
    <cfquery name="expire" datasource="#db#">
    update news
    set is_current = 0
    where exp_dat < now()
    </cfquery>
    What this ends up doing is filtering out the expired items correctly, but once a new row is inserted, the previous items(which haven’t expired yet)
    are still having the “is_current” column set to 0.
    The query is cfincluded on the page the messages are supposed to display on (breakingnews.cfm). 
    How can I get the query to loop over each row every time to check if the now() is earlier or later than “exp_dat” without setting all the other row’s “is_current” to 0?

    Two things:
    1 - A query will never affect rows you haven't told it to. Therefore if new rows have the is_current set to 0, then it's because you're either setting it so in your insert statement or you've set a default value on the column. Just make sure you set the column to 1 when you insert the new row.
    2 - Why are you doing this at all? Say you run your update query (which is relatively intensive) a millisecond before one expires, it'll still be shown on your page. Why are you not just doing "SELECT * FROM mytable WHERE expiration_date > now()"?
    Obviously use cfqueryparams, but that's just an example. It seems at the moment all you're doing is storing out-of-date data in a database and causing yourself a lot more work and overhead.

  • Expiration date not displaying after upgrade from 2007 to 2013

    I recently upgraded from MOSS 2007 to 2013.  I have information management set up on a library of InfoPath forms.  For the forms that were created prior to the upgrade, the expiration date is displaying and actually get updated if I modify them. 
    But none of my forms that have been created after the upgrade, are displaying when the expiration date is, which should be one year from modify date.  If I modify the forms created prior to the upgrade, they reflect the new, update date.
    Are these new forms not getting the policy applied to them, and why not?  I am not sure why the older forms are getting updated, but not my new ones.
    Denise E.

    Hi Denise,
    According to your description, my understanding is that the Expiration date column was not displaying values after upgrading from SharePoint 2007 to SharePoint 2013.
    Per my knowledge, we can only use the date column which is added to the library or list or the Declared Recorded date to set the retention policy, so if the Expiration date is used in the retention policy then the Expiration date should be a column in the
    library or list.
    I recommend to check the retention policy in the library and see which column is used in the retention policy as the image below shows:
    After that, go to the Library settings to find this column.
    Could you please provide screenshots of the retention policy and the columns in the Library settings page?
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • Dynamic  Lead Columns / Data Columns

    Hi
    I want to use dyanmic data columns restricted by a characteristic relationship of another variable.
    When I use the characteristic as a lead column, it works perfect, I only see the rows for valid lines.
    When I use the characteristic as a data column, I see all possible characteristic values of that characteristics. The ones that are not valid are not ready for input, the ones that are valid are ready for input.
    I would like to use dynamic data columns but only display the columns with a valid characteristic relationships (just the way it works when I put the characteristic in the lead column)
    Should that work?
    Thanks

    Enable Zero-Suppression on your column structure. Then in your Query properties, enable zero-suppresion for columns. That way only characteristic values with data will be shown and not all possible characteristic values present in the master data tables. I should note that there should be some data in the fact table which links the keyfigure to the characteristic value, otherwise it will be suppressed.

  • SCD Type 2 - effective/expiration dates

    OWB 11g 11.2.0.2
    I'm coming in cold to an environment where there's a business need to have a pair of start/end dates in a type 2 DIM, very simillar to the way the effective/expiration dates are maintained by OWB. The difference is that the end date in the closed record (becoming history) and the open date in the active record are not (the default) SYSDATE, but come from a source table/column in the mapping. There is no gap in these date/times.
    None of them seem to be working as intended. I know the concepts of type 2, but am not well-versed on working with them. I guess the first question is-- is it even possible to manipulate a column in a record as the dim controls the creation of a history record? It seems to me we are trying to mix manual and automated, and it won't work. But maybe there is a trick to this that I haven't yet learned.
    Any insights would be greatly appreciated.
    ~Peter

    Hi Peter,
    The difference is that the end date in the closed record (becoming history) and the open date in the active record are not (the default) SYSDATE, but come from a source table/column in the mapping.Is your source table already in SCD2 format (i.e. does it may contain multiple rows for single entity)?
    I guess the first question is-- is it even possible to manipulate a column in a record as the dim controls the creation of a history record?It is possible to change behaviour of populating of Effective Date column for SCD2 dimension - you can map Effective Date column from mapping parameter/source table columns/etc.
    But Expiration date column is poplated implicitly (for closed record) from value mapped to Effective Date column.
    Regards,
    oleg

  • Variable in Prompts instead of a Date column

    Hi,
    How do I create a presentation variable of type date to use it in the prompt? I do not want to use the date column, but use a variable to pass the start date and end date. This is because, I have two views in a report. Both the views accept different date columns as input. Can someone please guide me here to solve this issue?
    Thank You,
    AK

    Hi,
    I was able to pass values to two different views from the date prompt. The only issue I have is with the filter.
    This is what I have in the filter:
    VariableExpr = myPresentationVariableName
    default = valueof(myRepositoryVariableName)
    The report runs fine, but I see errors when I click on 'Results' tab in Answers. The errors say, "Expecting datetime value but got valueof(myRepositoryVariableName)"
    I even tried to Cast it to date which says CAST(valueof(myRepositoryVariableName) AS DATE). But it did not work.
    Am I missing anything here? The errors appear only in Results tab of Answers. When the report is run through the dashboard, it runs just fine.
    Thank You,
    AK

  • How to auto update date column without using trigger

    Hi,
    How to write below MYSQL query in Oracle 10g :
    CREATE TABLE example_timestamp (
    Id number(10) NOT NULL PRIMARY KEY,
    Data VARCHAR(100),
         Date_time TIMESTAMP DEFAULT current_timestamp on update current_timestamp
    I need to auto update the Date_Time column without using trigger when ever i update a record.
    Example shown below is from MYSQL. I want to perform the below steps in ORACLE to auto update Date_Time column.
    mysql> INSERT INTO example_timestamp (data)
    VALUES ('The time of creation is:');
    mysql> SELECT * FROM example_timestamp;
    | id | data | Date_Time |
    | 1 | The time of creation is: | 2012-06-28 12:37:22 |
    mysql> UPDATE example_timestamp
    SET data='The current timestamp is: '
    WHERE id=1;
    mysql> SELECT * FROM example_timestamp;
    | id | data | Date_Time |
    | 1 | The current timestamp is: | 2012-06-28 12:38:55 |
    Regards,
    Yogesh.

    Is there no functionality in oracle to auto update date column without using trigger??
    I dont want to update the date column in UPDATE statement.
    The date column should automatically get updated when ever i execute an Update statement.

  • Send Email alerts befor expiration date on list......

    Other than using SharePoint Designer or creating a workflow what other ways can be used to notify us  (by email) say, 2 weeks, before the expiration date column in a list record is hit?
    TIA,
    edm2

    Hi romeo,
    You can try to use timer job as suggested above, and set the timer job to run at specific time duration. in the timer job logic, check the expiration time in the list item field, and do your operation. Please get better understanding about timer job first,
    you will get to know how to do this.
    Thanks,
    Qiao Wei
    TechNet Community Support

  • Want to display a date in column heading.

    Hi all,
    Will be thankful, if anyone can tell me how to solve one of the issue i am facing in webi variable display.
    In universe, i am creating one prompt for date and user will enter the desired date, and with respect to that date, the previous date and previous month last working date will come. In my Webi report , i have 3 dates and one measure(Quantity) with other dimensions like Product and Subproduct. 
    I have one cross table in which in want to show the 3 dates as Column heading, Product as row heading and Quantity(measure) in the table body. I have one more dimension as Area... which i want to show in horizontal way, for each Area, i want to show prompted date, previous date and previous month last date. I have created 3 variables.... 
    1. Current date = Max(date) In Report
    2. Previous date = Min(date) In Report
    3. Previous Month last day = (date) where (Rank = 2) ForEach(date)
    By this way, I am able to show Current date and  Previous Month last day in column heading, but not Previous day. Will appreciate if anyone can help me on the issue. let me know if any other information is required.
    Thanks
    Archit Sarwal

    Hi,
    The previous date is the previous business day, it can be dynamic. And previous month's last day is last business day, it can also be dynamic. And Previous daye can also be previous month's last business day in one of the scenerio.
    Actually i am using 3 filters with prompts (common prompt) in universe side. User will enter the date and corrosponding previous business day and previous month's last business day will come. 3 filters are:
    1. Current_Day = @prompt('Enter Date(YYYYMMDD)','A',,Mono,Free,Persistent)
    2. Previous_Day = (SELECT TOP 1 Date from [TableName] where Date < @prompt('Enter Date(YYYYMMDD)','A',,Mono,Free,Persistent) Order By Date Desc)
    3. Prior_Month last Day = (SELECT TOP 1 Date from [TableName] T where Month(T.Date) = Month(DateAdd(mm,-1,@prompt('Enter Date(YYYYMMDD)','A',,Mono,Free,Persistent))) Order By T.Date Desc)
    Dates are coming correct from Universe.  In Webi, i have created variables...
    CurrentDate = max([Date]) In Report
    LastDate = Min([Date]) In Report
    PriorDate = [(Date]) where ([Rank]=2) ForEach ([Date])
    I have calculated Rank for Date, and Rank 2 shows the Prior Date. Also, i have Entity, and want to show these dates for each entity along with 2 -3 more columns that depends on these 3 dates values. I am attaching the screenshot for the sample.
    Thanks
    Archit Sarwal

  • From  date column I want to pick the hours only......

    Dear All
    I am facing the following problem.
    I having following date format in database of date column
    4/7/2006 10:26 AM
    4/7/2006 07:18 PM
    from this date column I want to pick the hours only , For ex. 10, 07 resp.from the above record.
    I tried it to solve using SUBSTR and LTRIM-TRIM function, but this functions will truncate the time format and so unable to pick the Hours.
    Is there any other solution for this.
    Also the date column I have is in 12 Hours(AM/PM) format I want to convert it into 24 Hours . Like 07 PM . I want it to 19.
    Thanks
    Vishal.

    TEST@db102 SQL> select * from test;
    C1
    4/7/2006 10:26 AM
    4/7/2006 07:18 PM
    TEST@db102 SQL> select to_char(to_date(c1,'dd/mm/yyyy hh:mi PM'),'hh24') from test;
    TO
    10
    19
    TEST@db102 SQL>                                               

  • 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]

  • Want to change backgroung of Date Column

    Hi Guys,
    I want to change background of Date Column of table but condition is if date is greater than today then it should be in Red otherwise no.Do i need to do this from beam ?
    Thanks,
    Raul

    Have a look at this:
    http://andrejusb.blogspot.ie/2010/04/changed-row-highlighting-in-oracle-adf.html
    http://www.techartifact.com/blogs/2009/05/conditionally-colouring-of-row-cell-in-adf.html
    or
    1. You can create a transient column to your VO with built in Groovy expressions like adf.currentDate.
    2. and compare with you date column and change inlinestyle like #{row.myDate > row.currentDate ? 'background-color:red' : 'background-color:blue'}
    Edited by: Lalit S on 7 Jun, 2013 10:59 AM

  • Insert document expiration date in a Word template

    Hello all,
    I have a problem I hope anyone can help me with. I need to include a column in Document Library with the Document expiration date and after that, include that expiration date into the Word templates I have in that library.
    In order to do that, I created a date column (not a calculated one) called "ExpDate" with a default value of Today + 365 as I want the document to expire one year after its creation. After that, I edit the word templates I have associated to the
    document library so as to include the new "ExpDate" column as a Quick part.
    The problem I find is the following: When I create a new document based in the document templates (through content types), the user has the chance to insert an expiration date (as it is metadata) or leave it empty (the column is not defined as mandatory). If
    the user leaves the expiration date empty, the new column is filled with the default value (today + 365 days) but when I open the word document I see the name of the column [ExpDate] instead of the default value.
    Is there a way of forcing the document information panel to be filled with the default value?
    Do you imagine an alternative solution to the requirement of including the expiration date inside the document without having to be defined by the user?
    Thanks a lot.
    Regards.

    Wordsub.llb should be somewhere in your Labview folder on your local drive. The path to it in my install is: C:\Program Files\National Instruments\LabVIEW 8.6\vi.lib\addons\_office\_wordsub.llb
    Also what specific problem are you referring to about 17 bookmarks? Is that the limit on the express style VI for filling them in from LV? If so what you will need to do is to use the lower level function 'Word Insert Field' under Word Advanced VIs. You will need to supply the VI the name of the bookmark and the text you want to insert.

  • How to make date column sortable which has inline case in report

    Hi all,
    I have date column which has inline case to check for expiration and display text 'expired' along with date. This column is set to be sortable. On sorting, it is doing based on char not on date. How can I retain this inline case along with getting correct sort order on clicking column header ?
    Thanks!

    982185 wrote:
    Hi all,Welcome to the forum: please read the FAQ and forum sticky threads (if you haven't done so already), and update your profile with a real handle instead of "982185".
    When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:
    <li>Full APEX version
    <li>Full DB/version/edition/host OS
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)
    <li>Browser(s) and version(s) used
    <li>Theme
    <li>Template(s)
    <li>Region/item type(s) (making particular distinction as to whether a "report" is a standard report, an interactive report, or in fact an "updateable report" (i.e. a tabular form)
    With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.
    I have date column which has inline case to check for expiration and display text 'expired' along with date. This column is set to be sortable. On sorting, it is doing based on char not on date. How can I retain this inline case along with getting correct sort order on clicking column header ?Note comments above regarding the importance of stating whether you are using a standard or interactive report.
    Here's 2 possible techniques, which you can modify to fit how you want "expired" values to be sorted:
    <li>{message:id=10609805}
    <li>{message:id=4175275}
    The second one is the best approach if using a standard report, or an interactive report in APEX 4.2.

Maybe you are looking for