Date comparison in UNIX

Hi All,
Can some one please suggest me, how to compare the date in unix.
I'm using below command but its not comparing the dates correctly
bankdate=25-JUL-2009
start_date=01-JUL-2009
end_date=31-JUL-2009
echo bankdate="${bankdate}"
echo start_date="${start_date}"
echo end_date="${end_date}"
if (( bankdate >= start_date && bankdate <= end_date ))
then
echo "bank date is in current period"
else
echo "bank date is not in current period"
fi
its giving the below result:
bankdate=25-JUL-2009
start_date=01-JUL-2009
end_date=31-JUL-2009
testp.sh: bankdate: not found
bank date is not in current period
Please suggest me what is wrong in the above...
Thanks in advance,

Hi Reynolds,
Thanks for the reply,
below are the answers for your questions:
#!/bin/bash
{' 'c' 'o' 'd' 'e' '}'
bankdate=25-JUL-2009
start_date=01-JUL-2009
end_date=31-JUL-2009
echo bankdate="${bankdate}"
echo start_date="${start_date}"
echo end_date="${end_date}"
if (( bankdate >= start_date && bankdate <= end_date ))
then
echo "bank date is in current period"
else
echo "bank date is not in current period"
fi
{' 'c' 'o' 'd' 'e' '}'
Output of the above code is
'Output start'
bankdate=25-JUL-2009
start_date=01-JUL-2009
end_date=31-JUL-2009
testp.sh: bankdate: not found
bank date is not in current period
'Output end'
2) your correct i'm using bash.
3) i'm getting the date format from sql session created in the script. If it is very difficult to work with 'DD-MON-YYYY' format i can change it to the other format.
Please suggest me the best solution for this.
Thanks,

Similar Messages

  • Report customer master data comparison

    Hello Experts,
    Using transaction SE38, we would like to run report customer master data comparison. Could anyone provide the report name?
    Thank you

    Hi Thanks.
    Can you provide report used for sales summary?
    Thanks again

  • Idoc data  comparison between different R/3 clients.

    Hi ppl ,
    Is there a way idoc comparison can be done between different clients without going
    by Segment by Segment comparison ?
    I have a requirement wherein i have thousands of idocs in QA system and i need to
    compare those with the ones in PROD system. The segments in the idocs may vary
    depending on the data that flows from the third party system which will post idocs in R/3.
    So, the segment wise comparison of data is also ruled out .
    Do we have any standard reports which will help in achieving this purpose ?
    Please let me know how the idoc data comparison can be carried out .
    Regards,
    Nick.

    Hi Nick,
    There is no standared tools available for comparing the data of two idocs.
    By using beyond compare s/w you can check the data, but the thing is you have to download the idoc data to file format.
    By using Idoc_xml_transform function module you can download idoc data to xml format, after you can compare.
    Check this
    http://download.cnet.com/Beyond-Compare/3000-2242_4-10015731.html
    Regards
    Ramesh

  • Time "and" Date Comparison

    Hi,
    I am trying to get the difference between two sets of time.
    This also involves a Date comparison because sometimes the times span more than one day.
    Here is an example of what I'm trying to accomplish. I have searched the forum archives but have not yet found time and date comparisons together.
    startRun = "10/26/01 4:30 PM";
    endRun = "10/27/01 7:45PM";
    I want to process these two times and get the difference.
    The result would be:
    totalRunTime = "27 hours 15 minutes";
    I am stumped. Is this type of process even possible? Any help would be grealty appreciated.
    Best,
    Christian Velez
    Senior Software Engineer
    Research Institute of America, Inc.
    [email protected]

    try this ...
            String startRun = "10/26/01 4:30PM";
            String endRun = "10/27/01 7:45PM";
            SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mma");
            try {
                Date startDate = sdf.parse(startRun);
                Date endDate = sdf.parse(endRun);
                System.out.println("Start date/time = " + startDate);
                System.out.println("End   date/time = " + endDate);
                long differenceInMillis = endDate.getTime() - startDate.getTime();
                long differenceInSecs = differenceInMillis / (1000);
                long differenceInMins = differenceInMillis / (1000 * 60);
                long differenceInHours = differenceInMillis / (1000 * 60 * 60);
                System.out.println("Millis = " + differenceInMillis);
                System.out.println("Seconds = " + differenceInSecs);
                System.out.println("Minutes = " + differenceInMins);
                System.out.println("Hours   = " + differenceInHours);
                //What you want
                System.out.println("Total run time = "
                    + differenceInHours + " hours "
                    + (differenceInMins % 60) + " minutes");
            } catch (ParseException pe) {
            }

  • OBIEE Date Comparison report with multiple measures

    Hello everyone...
    I have a requirement where I need to create a date comparison report (Current Month vs. Prior Month vs Prior Month Year Ago vs YTD vs Prior YTD vs Rolling 3 months, etc) with multiple Measures (Quote count, Quote offered count, New Business count, etc). I am to generate this report in this fashion:
    Quotes Current Month vs PM vs YoY Prior
    Month Current Month Prior Year Current
    YTD vs PM Prior
    YTD Rolling 3 Months vs PM Prior Rolling 3 Months
    Issued 120 120 123 1400 1020 1700 1580
    Unique Risks
    Offered 556 449 571 5881 6220 6101 5892
    Unique Risk Close Ratio
    Offered Close Ratio 21.6% 26.7% 21.5% 23.8% 16.4% 27.9% 26.8%
    Bitmap
    Avg Issued Premium 240 238 222 2801 2630 3104 2892
    Avg Offered Premium
    New Business
    Count
    Avg Full Term Premium
    I understand that time series is an option, and have created the time series (which show up as measures).
    My problem is:
    when creating the report (even as a pivot table) , OBIEE is not allowing me to drag the measure to rows, nor is it allowing me to drag the time series to columns. Also, I need to do conditional formating on some of the columns showing an up arrow for increased vs. prior month and down arrow for decreased vs. prior month.
    Does anyone have a solution for this issue? Any assistance would be greatly appreciated...
    Please advise and thanks!!!

    Jason,
        You've been very helpful, but I guess I'm just not explaining myself that well. The Credit Memo's throw things off because they do not contain a "Paid Date" value. That field in the record is blank. Since it is blank the report query ignores them. Therefore when the report query returns all records that have a "Paid date" range of "x to y" they are never returned. This is a problem whenever a credit memo exists for an invoice because the "invoice total" never changes. So when a customer pays on their account for a particular invoice, they only pay what is due which is the "invoice total" minus any "credit" from the "Credit Memo". So when my A/R person receives payment they are showing the invoice paid in full because MAS automatically includes all invoices and credit memo's. My report does not because there is no data in the "Paid Date" field of the record for Credit Memos.
    I've been doing alot research in trying to resolve this "exception" to my report. I think I may be on to something, but my knowledge of arrays is extremely limited. My resolution involves populating an array with the "invoice numbers" that are returned from the initial query from the supplied date range. Then using the "invoice numbers" from the array have it then populate my details section of the report with all of "invoice records" both the actual invoice record and any "credit memo" records. I can then group the records returned  based upon the "invoice number". then within that grouping I can performing my calculations to show whether or not the invoice has been paid in full. What do you think?  I've been able to populate an array with the invoice numbers based upon my date search range, but I have yet to figure out how to take that information and perform another lookup to pull in the rest of the data I need. Do you have any ideas?
    Thanks.  Bill

  • Data comparisons and movements

    I have a Heap Sort using the following code, and I cannot seem to figure out how many data comparisons and data movements there are as the heap is sorted. Does anybody know how to count the number of comparisons and movements?? Please let me know....much appreciated...Thanks :)
    import java.io.IOException;
    import java.util.*; // Calender Class for timing
    public class Heap {
    private MyNode[] heapArray;
    private int maxSize;
    private int currentSize; // number of items in array
    public Heap(int mx) {
    maxSize = mx;
    currentSize = 0;
    heapArray = new MyNode[maxSize];
    public MyNode remove()
    MyNode root = heapArray[0];
    heapArray[0] = heapArray[--currentSize];
    trickleDown(0);
    return root;
    public void trickleDown(int index) {
    int largerChild;
    MyNode top = heapArray[index];
    while (index < currentSize / 2)
    int leftChild = 2 * index + 1;
    int rightChild = leftChild + 1;
    // find larger child
    if (rightChild < currentSize
    heapArray[leftChild].getKey() < heapArray[rightChild]
    .getKey())
    largerChild = rightChild;
    else
    largerChild = leftChild;
    if (top.getKey() >= heapArray[largerChild].getKey())
    break;
    heapArray[index] = heapArray[largerChild];
    index = largerChild;
    heapArray[index] = top;
    public void displayHeap() {
    int nBlanks = 32;
    int itemsPerRow = 1;
    int column = 0;
    int currentIndex = 0;
    while (currentSize > 0)
    if (column == 0)
    for (int k = 0; k < nBlanks; k++)
    System.out.print(' ');
    System.out.print(heapArray[currentIndex].getKey());
    if (++currentIndex == currentSize) // done?
    break;
    if (++column == itemsPerRow) // end of row?
    nBlanks /= 2;
    itemsPerRow *= 2;
    column = 0;
    System.out.println();
    else
    for (int k = 0; k < nBlanks * 2 - 2; k++)
    System.out.print(' '); // interim blanks
    public void displayArray() {
    for (int j = 0; j < maxSize; j++)
    System.out.print(heapArray[j].getKey() + " ");
    System.out.println("");
    public void insertAt(int index, MyNode newNode) {
    heapArray[index] = newNode;
    public void incrementSize() {
    currentSize++;
    public static void main(String[] args) throws IOException {
    int size, i;
    size = 500;
    Heap theHeap = new Heap(size);
    for (i = 0; i < size; i++) {
    int random = (int) (java.lang.Math.random() * 5000);
    MyNode newNode = new MyNode(random);
    theHeap.insertAt(i, newNode);
    theHeap.incrementSize();
    System.out.println(size+" random numbers are currently being generated...");
    for (i = size / 2 - 1; i >= 0; i--)
    theHeap.trickleDown(i); // creates the heap
    System.out.print("\nRandom Numbers in a Heap: ");
    theHeap.displayArray(); // prints the heap
    long time1000start = new Date().getTime() ; // this makes a new Date object and then sets the long integer value of the Date object
    // ******************* START - sorting numbers *******************
    for (i = size - 1; i >= 0; i--)
    MyNode biggestNode = theHeap.remove();
    theHeap.insertAt(i, biggestNode);
    // ******************* END - sorting numbers *******************
    long time1000end = new Date().getTime() ; // this makes a new Date object and then sets the long integer value of the Date object
    double timediff1000m = (time1000end - time1000start); // difference of time in milliseconds
    double timediff1000s = ((time1000end - time1000start) / 1000); // difference of time in seconds
    System.out.print("\nRandom Numbers in a Sort: ");
    theHeap.displayArray(); // prints the numbers in increasing order
    System.out.print("\nStart Time of Sort: "+time1000start);
    System.out.print("\nEnd Time of Sort: "+time1000end);
    System.out.print("\nTime to Complete Sort: "+timediff1000m+" milliseconds or "+timediff1000s+" seconds.");
    } // end main method
    } // END project :)

    I never miss class....my instructor gave us the assignment of making a heap sort and he told us to use code off the internet as a resource because the only sorting we have done so far is bubble.....this was a research project, for my instructor to see if we can use the internet as an effective resource to put together a program and learn about a differnet type of sorting.....everyone in the class got a different type of sort (merge, quick, insertion, etc...). i have put the program together and customized it to my needs based on my knowledge.....the last thing i am having trouble with is my counting of comparisons and data movements. Can you please help me finish up my program.

  • Question on How to Use LI and NP Data Comparison Report

    Hi,
    We are trying to figure out how to make the Transaction Code PC00_M42_LLPD (LI and NP Data Comparison Report) work. What file type (.xls, .txt, etc) should be used?  Anyone who is familiar with the transaction, please help.
    Best Regards,
    Bry

    Somewhere in the Oracle 8.0 documentation it is stated that one
    enviroment per each thread is required if I want to ensure
    complete concurrency of different threads accessing databases.
    But isn't this a waste of resources since only Handle Alloc &
    Free functions use Enviroment handle, hence they should be
    mutexed for access from concurrent threads.
    But the most time-consuming functions are ServerAttach &
    SessionBegin which shouldn't be mutexed since they have each
    their own Server/Session handle.
    So my question is if a single OCI Enviroment is enough for the
    most demanding tasks or should I create one enviroment per
    thread?
    Most folks are happy with a single environment. The mutex on the
    env handle is only taken when the OCI library is allocating some
    memory for internal operations.
    Tomislav.

  • Install Data Services on UNIX Solaris

    Hi all,
    I`m trying to install Data services on Unix solaris and when I write ' ./install.sh' on command line it show this:
    SunOS: Your system is missing required components:
    Missing package:CE-unsup
    If you continue your installation maybe not work correctly.
    Please press Enter to continue.....
    (I press Enter)
    Patch checking complete
    /tmp/Data_services/perl/boperl.sh: line 18: bin/perl: cannot execute [Invalid argument]
    /tmp/Data_services/perl/boperl.sh[88]: /tmp/Data Services/perl/bin/perl: /tmp/Data_Services/perl/bin/perl:cannot execute [invalid argument]
    sybase@opensolaris: /tmp/Data_services
    Any idea whit this problem?
    Thanks in advance.

    Hi Eduardo,
    if its not in there its not supported.
    I made the experience that it somethimes work installing a BO product on a not supported UNIX OS. But that was mainly BOE not DS.
    Maybe you can install DS on open Solaris but you wont get support for it.
    If you really need to know when or if open solaris is supported than i would suggest you raise a Support MEssage at SAP.
    Regards
    -Seb.

  • Transfering Date field into UNIX server

    Hi,
    I transferring date field to UNIX server from SAP which later read by MAINFRAME system from UNIX server.I would like to transfer the date field with length 5 into Unix server.I tried to transfer using PACK, but packed date is not readable to validate the unix file.Can anybody help me out on this.
    Thanks in Advance,
    Kilaru

    hi,
      For writing the fields into Unix file, they have to character fields.
      to pass a date field, try like this.
    data: v_date(10) type c.
      concatenate sy-datum6(2) sy-datum4(2) sy-datum+0(4) into  v_date separated by '/'.
      now send v_date to unix file.
    Regards,
    Sailaja.

  • How to access Oracle Data Base on Unix using Visual Basic ?

    Hi !
    I want to use visual basic and access the Oracle Data Base on Unix server. How can i do that ? Do i need any software?
    .Prashant

    You need an oracle client installation and setup your TNS names.

  • Date comparison in scripts

    Hi all,
    /: If &vbrk-fkdat& <  '31.12.2006'.
    /:    include my_logo.
    /: else.
    /:    include your_logo.
    /: endif.
    I want to compare dates in scripts text element. how to do.
    the &vbrk-fkdat& is holding 19.06.2006. and showing 'your_logo' but i need 'my_logo'.
    Please find out is there any mistake in dates comparison. or let me know how compare dates
    Helpful answeres are surely rewarded.

    Hi all,
    Thanks for your suggestions.
    the solution is
    /: define &dates& = '31.12.2006'.
    /: SET DATE MASK = 'YYYYMMDD'.
    /: If &vbrk-fkdat& < &dates&.
    /: include my_logo.
    /: else.
    /: include your_logo.
    /: endif.
    /: SET DATE MASK = ''. -
    > to reset date mask

  • Date Comparison Error

    I have a database column named lastname this has text data entered in form of: 05/15/2010  and so on.  ---long story on why text field and not date....
    My code is as follows:
    select b.lastname as sale_date, c.combined_legal as legal_address
      from anthem_prod_usr.opr_logi_documents      a
      ,    anthem_prod_usr.opr_parties             b
      ,    anthem_prod_usr.opr_legal_headers       c
      ,    anthem_prod_usr.image_references        f
      ,    prod_pa.valid_dates                     g
    where a.instrument_number = b.instrument_number
       and a.multi_seq = b.multi_seq
       and b.name_type = 'E'
       and b.lastname like ('__/__/____')
       and a.instrument_number = c.instrument_number
       and c.multi_seq = c.multi_seq
       and trunc(to_date(b.lastname,'mm/dd/yyyy')) between trunc(to_date('07/10/2010','mm/dd/yyyy')) and trunc(to_date('08/01/2010','mm/dd/yyyy'))
       and f.content_type_id = 'PUBLIC'
       and a.document_type = 'FORECLOSURE'
    Error I receive is:
    ORA-01843: not a valid month
    01843. 00000 -  "not a valid month"
    *Cause:   
    *Action:
    Using trunc function, I thought I was trimming time off to do only date comparison.  Not sure why this error occurs.

    Hi,
    This shows one of the many reasons why storing date information in VARCHAR2 columns is such a bad idea.
    TRUNC is irrelevant here.  The error occurs in TO_DATE.  You're doing TRUNC on the results of TO_DATE, so nothing you do with TRUNC will affect the error.
    You must have some bad data in the column.  If you can't actually clean up the table, then you have to detect the bad data before attempting TO_DATE.
    Remember, the optimizer decides which conditions in the WHERE clause will be done first.  There's no guarantee that
    and b.lastname like ('__/__/____')
    will be applied before TO_DATE.  Even if it is, the condition above is just testing that the string is the right length and has slashes in the right places.  It's checking that (for example) the month is between '01' and '12', or even if the month is numbers.  The string '//////FOO/' meets the condition above.
    See https://forums.oracle.com/message/4255051 for validating date information in SQL.
    If you need help, post a complete test case that people can run to re-create the problem and test their ideas.  Include CREATE TABLE and INSERT statements for any tables needed. Also post the results you want from that sample data given.
    Simplify the problem as much as possible.  Remove any tables or conditions or anything else that isn't related to the problem.
    See the forum FAQ https://forums.oracle.com/message/9362002#9362002

  • Oracle DB schema and data comparison tools that compare BLOBs

    I'm looking for schema and data comparison tool like DBDiff or DbTools, but it has to be able to compare BLOB and CLOB fields. I went thru few products available on the market but could not find any that does that.
    Can you please recommend tool that will help me with it.
    Thanks,
    E

    Hi.
    I use Comparenicus for Oracle from Orbium Software. It compares data and schema, CLOBs, BLOBs..
    It can also handle large tables which is very useful for some of my environments.
    Last (but not least) it has a unique feature for copying selective data from one DB to another. You can read about it this post:
    Efficient way to copy business data from Production DB to Test DB
    Enjoy..

  • Doubt regarding Date Comparison

    Hello,
    i am facing a problem in date comparison
    SELECT max(l.id)
    FROM irf_bill_details l
    WHERE to_char(l.agreement_id) = '508814'
    AND l.billing_client_id = 'BHPIF'
    AND extract(YEAR FROM l.bill_date) < extract(YEAR FROM to_date('01-Jan-2010', 'dd-Mon-yyyy'))
    So when i am using this Query m getting the result ...BUT ...
    When i use the Below Query .... i am getting NULL ... So the problem surely is in when comparing with months ..?? how to get rid
    SELECT max(l.id)
    FROM irf_bill_details l
    WHERE to_char(l.agreement_id) = '508814'
    AND l.billing_client_id = 'BHPIF'
    AND extract(YEAR FROM l.bill_date) < extract(YEAR FROM to_date('01-Jan-2010', 'dd-Mon-yyyy'))
    AND extract(MONTH FROM l.bill_date)||'-'||extract(YEAR FROM l.bill_date) < extract(MONTH FROM to_date('01-Jan-2010', 'dd-Mon-yyyy'))||'-'||extract(YEAR FROM to_date('01-Jan-2010', 'dd-Mon-yyyy'))
    --------------------------------------------------------------------------------------

    Aijaz Mallick wrote:
    Hello,
    i am facing a problem in date comparison
    SELECT max(l.id)
    FROM irf_bill_details l
    WHERE to_char(l.agreement_id) = '508814'
    AND l.billing_client_id = 'BHPIF'
    AND extract(YEAR FROM l.bill_date) < extract(YEAR FROM to_date('01-Jan-2010', 'dd-Mon-yyyy'))
    So when i am using this Query m getting the result ...BUT ...
    When i use the Below Query .... i am getting NULL ... So the problem surely is in when comparing with months ..?? how to get ridAre you saying that you're still getting one row of output, but the id on the row is NULL?
    SELECT max(l.id)
    FROM irf_bill_details l
    WHERE to_char(l.agreement_id) = '508814'
    AND l.billing_client_id = 'BHPIF'
    AND extract(YEAR FROM l.bill_date) < extract(YEAR FROM to_date('01-Jan-2010', 'dd-Mon-yyyy'))
    AND extract(MONTH FROM l.bill_date)||'-'||extract(YEAR FROM l.bill_date) < extract(MONTH FROM to_date('01-Jan-2010', 'dd-Mon-yyyy'))||'-'||extract(YEAR FROM to_date('01-Jan-2010', 'dd-Mon-yyyy'))
    --------------------------------------------------------------------------------------Whenever you have a problem, post some sampel data (CREATE TABLE and INSERT statements) and the results you want from that data. Explain how you get those results from that data.
    As long as I don't know where you're starting from (sample data) or where you want to go (results) it's hard for me to give you good diorections.
    I suspect you want to be using TRUNC rather than EXTRACT, if not a plain DATE comparison.
    For example, if you have a string p_cutoff_date (such as '01-Jan-2010', but not necessaily the 1st of the month) and you want to see if l.bill_date is earlier than the beginning of the month that contains p_cutoff_date, then:
    WHERE   l.bill_date < TRUNC ( TO_DATE ( p_cutoff_date
                                          , 'dd-Mon-yyyy'
                       , 'MONTH'
                       )As you said in the subject line, you're trying to compare DATEs. So compare DATEs: don't convert them to NUMBERS (using EXTRACT) and then to strings (using ||); keep the DATEs as DATEs.

  • Date Comparison

    Hello All,
    UCCX 9
    Scenario: I would like the script to do a date comparison so that if Today's date is before xx/xx/xx or after xx/xx/xx I can direct it to different steps in the scripts.
    I have 3 string variables
    Current_Date  - Changes depending on the day
    Begin_Date    - 2/1/2014
    End_Date      - 2/10/2014
    Step 1
    I have an IF statement
    If Current_Date < Begin_Date
    -True Goes to Time_of_Day_check
    -False Goes to End_Date_check
    Step 2
    If the above outcome is False it checks the End_Date
    IF Current_Date >End_Date
    -True   Goes to Time_of_Day_check
    -False Goes to Alternative Time_Of_Day_check
    The issues I'm having is with Step 2
    When the End_Date is less than 2/6/2014 it works fine.
    For example if End_date is 2/3/2014 it goes to True, which is correct.
    However,
    When the date is 2/10/2014, it still goes to True.., which is incorrect
    When I change the End_Date to 3/1/2014, then it starts going to False
    Am I unable to compare dates like this?  Is there a better way to compare dates?
    Thank you,

    I'm not sure I understand what you're doing, in order to give you an answer, however, I can tell you that Date objects, not Strings, are what you're going to want to work with when performing comparisons.
    Date object values are also just a Long value for the number of milliseconds since Jan 1, 1970 at 00:00:00.000 AM.
    It's key that you understand that it's the number of millisecond that it's holding.  Which explains why this is true today:  D[now] > D[2/6/2014].  Today being 2/6/2014 of course.  That because D[now] holds the current time the step is executed, whereas D[2/6/2014] is left to hold the time 00:00:00.000.  And no matter what time it is when the script executes, there's only a 1/86400000th of the day's time that they will be equal, which will make the conditional false.  Therefore, you would enter D[now] >= D[2/6/2014], which would be true for all 86400000 milliseconds of the day.  I, like you, would have expected that original condition to be false, because today is not after 2/6/2014; today is 2/6/2014.
    The easiest way, in my opinion, to compare two dates, without consideration for their time values, is to reset the time values of both objects to the same value.
    E.g.,
    Set today = new Date()Set today = new Date(today.getYear(), today.getMonth(), today.getDate())Set start_date = new Date(2014 - 1900, 2, 6)Set end_date = new Date(2014 - 1900, 2, 14)If (today >= start_date && today <= end_date)     True          Goto Alt ToD     False          Goto ToD
    Anthony Holloway
    Please use the star ratings to help drive great content to the top of searches.

Maybe you are looking for