Comparison in date

hi all,
can anybody tell me, how we can compare the dates?
i have a bdc for billing date and i want to compare my XL billing date to system billing date, my requirement is XL billing date should not Lesser than system billing date. can anybody help me that how should i do ?
its urgent..... suitable ans will be rewarded.
regards saurabh.

hi
Compare year, month and date separately.
EX :-
if date10(4) <= date20(4) and date14(2) <= date24(2) and date16(2) <= date26(2).
Regards
Prajwal K

Similar Messages

  • Comparison of Data Loading techniques - Sql Loader & External Tables

    Below are 2 techniques using which the data can be loaded from Flat files to oracle tables.
    1)     SQL Loader:
    a.     Place the flat file( .txt or .csv) on the desired Location.
    b.     Create a control file
    Load Data
    Infile "Mytextfile.txt" (-- file containing table data , specify paths correctly, it could be .csv as well)
    Append or Truncate (-- based on requirement) into oracle tablename
    Separated by "," (or the delimiter we use in input file) optionally enclosed by
    (Field1, field2, field3 etc)
    c.     Now run sqlldr utility of oracle on sql command prompt as
    sqlldr username/password .CTL filename
    d.     The data can be verified by selecting the data from the table.
    Select * from oracle_table;
    2)     External Table:
    a.     Place the flat file (.txt or .csv) on the desired location.
    abc.csv
    1,one,first
    2,two,second
    3,three,third
    4,four,fourth
    b.     Create a directory
    create or replace directory ext_dir as '/home/rene/ext_dir'; -- path where the source file is kept
    c.     After granting appropriate permissions to the user, we can create external table like below.
    create table ext_table_csv (
    i Number,
    n Varchar2(20),
    m Varchar2(20)
    organization external (
    type oracle_loader
    default directory ext_dir
    access parameters (
    records delimited by newline
    fields terminated by ','
    missing field values are null
    location ('file.csv')
    reject limit unlimited;
    d.     Verify data by selecting it from the external table now
    select * from ext_table_csv;
    External tables feature is a complement to existing SQL*Loader functionality.
    It allows you to –
    •     Access data in external sources as if it were in a table in the database.
    •     Merge a flat file with an existing table in one statement.
    •     Sort a flat file on the way into a table you want compressed nicely
    •     Do a parallel direct path load -- without splitting up the input file, writing
    Shortcomings:
    •     External tables are read-only.
    •     No data manipulation language (DML) operations or index creation is allowed on an external table.
    Using Sql Loader You can –
    •     Load the data from a stored procedure or trigger (insert is not sqlldr)
    •     Do multi-table inserts
    •     Flow the data through a pipelined plsql function for cleansing/transformation
    Comparison for data loading
    To make the loading operation faster, the degree of parallelism can be set to any number, e.g 4
    So, when you created the external table, the database will divide the file to be read by four processes running in parallel. This parallelism happens automatically, with no additional effort on your part, and is really quite convenient. To parallelize this load using SQL*Loader, you would have had to manually divide your input file into multiple smaller files.
    Conclusion:
    SQL*Loader may be the better choice in data loading situations that require additional indexing of the staging table. However, we can always copy the data from external tables to Oracle Tables using DB links.

    Please let me know your views on this.

  • How to Create an Input Schedule Comparison with Data Using EVDRE

    Hello,
    I try implement the scenario described in "How to Create an Input Schedule Comparison with Data Using EVDRE".
    Once I am using the "Insert Function" from the panel and selecting the EVTIM function Excel crashes (see page 8 How to paper).
    Systems:
    BPC 7.0 NW SP02
    Office 2007
    BPCADminClient and BPCOfficeClient up to date
    Have anyone a solution?
    Thanks
    Oktay

    Hi Oktay -
    This function works in my BPC70NW SP02 system. Your issue might be that you are trying to access a TIME member that does not exist. Please make sure the offset value is a valid dimension member.
    I can confirm that EVTIM does allow the offset for base members (such as 2009.MAY) as well as parent nodes (such as 2009.Q1 or 2008.TOTAL)... BUT...the offset result of the EVTIM function needs to be a valid dimension member!
    Regards,
    Sheldon

  • Comparison of dates using Oracle Business Rule

    Hi to everyone! I have a business rule that has as input parameter a complex attribute with a date field inside named expiration. I want to compare the expiration field with the current date using a comparison function. I don't know where find the current date. The function Calendar.getInstance() return the current date? Any help we'll' be highly appreciated.

    Calendar.getInstance() will give you the current date, and to find out the days between two dates; use Duration.days between(date1, date2) + 1

  • Novice :comparison of dates

    i ran a query to extract all employees who are hired before the manager of his department. But when comparing
    e.Hire_date < m.Hire_date(self join)
    it was giving me those employees also who were hired after the manager of his department.
    When i used
    to_date(e.Hire_date,'dd-mon-rr')<to_date(m.Hire_date,'dd-mon-rr')
    it gave the correct result.
    to_date() fuction is used to convert date to Oracle Propietary Format coz Oracle only excepts in this format('dd-mon-rr') so when we are just retrieving the date y do we have to use To_Date() function.
    explain this ?

    Is HIRE_DATE an actual DATE column? Or is it a string?
    Can you post the data and the SQL statement you're using? At the moment, my wager is that there is a bug in your code.
    Justin

  • Comparison of Date to select records

    Hi All,
    I am using ODI interface to select few records from an Oracle table which have their column "creation_dt" greater than a specific date. But i am facing error while executing it. I will explain you the steps i follow:
    1. Created 2 variables of type date: var_StartRefresh & var_LastRefresh. Start refresh variable has a code in refresh tab of variable declaration as "select sysdate from dual" where as LastRefresh will be used to save the vale of StartRefresh. Lastrefresh has been assigned a default value.
    2. Created an interface where source has a filter to filter out records which have records having column value for creation_dt greater than LastRefresh, written as follows:
    +(CREATION_DT - #Utility.var_LastRefresh) > 1+
    I created a package in which StartRefresh value is refreshed. Then interface runs followed by LastRefresh value being assigned the value of StartRefresh.
    But when i execute this package, it fails with following error at the load data step:
    com.sunopsis.sql.SnpsMissingParametersException: Missing parameter
    at com.sunopsis.sql.SnpsQuery.completeHostVariable(Unknown Source)
    at com.sunopsis.sql.SnpsQuery.updateExecStatement(Unknown Source)
    at com.sunopsis.sql.SnpsQuery.executeQuery(Unknown Source)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execCollOrders(Unknown Source)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(Unknown Source)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt(Unknown Source)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(Unknown Source)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(Unknown Source)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(Unknown Source)
    at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(Unknown Source)
    at com.sunopsis.dwg.cmd.DwgCommandBase.execute(Unknown Source)
    at com.sunopsis.dwg.cmd.DwgCmd.k(Unknown Source)
    at com.sunopsis.dwg.cmd.f.z(Unknown Source)
    at com.sunopsis.dwg.cmd.DwgCmd.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:619)
    Though When i replace this var_Lastrefresh with sysdate, it works fine
    Edited by: user8628169 on Mar 2, 2012 10:38 AM

    what i can think of is that #Utility variable is always of a character type and you may want to to_date() it.
    If that doesnt work, then try NVLing it as well to make sure that variable is indeed set to the value that you think it should be set to.
    I think you are using ODI 10g. So, you may want to raise the value of the variable to make sure that the default value is actually being set.

  • One field based on another by comparison of dates

    I have the following fields on my form: "seq_num", "start_date", "status". I'm trying to add new fields called "previous_seq_num", "previous_start_date", and "previous_status". Basically, these will need to reflect all previous sequence numbers and corresponding start dates and status for the current record in consideration. (each record is queried by a field called "company_id"). All the data is coming from a single table called "my_companies" and all the form fields are within the same block. I'm a newbie to forms and am getting confused about how to populate the "previous" data based on the current information. What I basically need to do is pull all the records for the "company_id" whose start_date is before the start_date in the current record.
    I'm creating my form in Oracle Designer. Can someone please guide me with this issue?
    Any help is greatly appreciated.

    Andreas,
    Thank you very much for your response.
    The following query will achieve the result that I want..it will generate all the rows from the table based on my requirement. The parameter "p_company_id" will be the current company under consideration and "pdate" is the start_date for the current record in focus.
    Here's the query:
    select am.seq_num, am.start_date, am.status_code
    from
    select seq_num, start_date, status_code,
    last_value (start_date) over (order by start_date) as lv
    from my_companies
    where company_id = :p_company_id
    ) am
    where am.lv <  to_date(:pdate,'mm/dd/yyyy')
    order by am.start_date;Conceptually, this query makes sense and can get all the data I need. I'm not sure how I should implement this in my form. Can you help me with that?
    Thanks, once again, for your time.

  • Comparison of dates

    Gurus,
    In a table, I have date column ... From_date1. In another table I have another date column ... To_date1. Both of them can be joined using common column (item) Now I want to see which date(From_date1 to sysdate, To date1 to sysdate) is lesser, how can I find it out ?
    Regards
    Edited by: Seshu2 on Sep 22, 2008 6:15 AM

    why subtract one date from another?
    Just do a least on the two dates...
    SQL> select least(sysdate, sysdate-1) from dual;
    LEAST(SYS
    21-SEP-08
    SQL>

  • Just used Match consolidations & match comparison with data quality for add

    I recently started to look for jobs on BODS and data quality i used data quality match consolidations.
    Are there any ither impt elements which are widely used in the industry from data quality perspective?
    Kind regards.
    Edited by: cplusplus1 on Feb 8, 2012 7:08 AM

    I am not entirely sure I understand your question.  We do have Data Quality blueprints for use in Data Services available.  You can find these on the SCN.
    The SAP Community Network hosts several Data Quality blueprints which are available for download.  Go to http://www.sdn.sap.com/irj/sdn/ds, and if necessary enter your user id and password or create an account.
    Scroll down to Downloads and click the link in Samples Data Services Blueprints.  There are several download packages that specialize in different areas and one that has all available samples contained in one download package.
    Note: A "review" page displays after clicking the link of the blueprint to be downloaded. Click View this Code Sample to download the file.
    Hope this is helpful.
    Thanks,
    Paula

  • 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

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

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

  • How to compare delivery date in schedule lines and PGI in outbound delivery

    Hi,
    I want to create a report to monitor and compare different dates in sales and delivery process.
    One of my key figure is the comparison between date confirmed to the customer, that I can find in the schedule line of the sales order, and the actual goods issue date from the outbound delivery.
    But I can't succeed in making the link between delivery and schedule lines, means between LIKP and VBEP.
    Would you have any idea?
    Thank you.

    It seems there's no exact (table) connection / link between delivery item and schedule line item.
    Those who were searching for this thing (link / connection between delivery item and schedule line) were recommended to use FM "RV_SCHEDULE_CHECK_DELIVERIES".
    This FM calculates the delivered quantity for each schedule line, so it makes link between the delivery item and schedule lines - however if you check the code it's quite sophisticated...
    (if you put a breakpoint in the FM and display a SO in VA03, you can check how the parameters have to be populated with data).
    Schedule Line and Delivery Link
    Edited by: Csaba Szommer on Aug 5, 2011 12:03 AM

  • I made a new Date object

    See, here's the thing with dates in java, the way i see it. We used to have Date, but Date wasn't international so we got Calendar. But some things, like SimpleDateFormat, still expect java.util.Date. java.sql.Date is out there somewhere, too. None of them have direct support for date differences (i.e. dateA - dateB = 8 days, or whatever). Now you're probably reading this thinking "Java supports all of this" and you're right. Calendar has a getTime method that returns a Date, and i can just pass THAT to SimpleDateFormat. With a little math, getTimeInMillis can be used to find the difference in two Calendars. But i got to thinking, "There should only be one Date object i need to think about," and since i don't ever have enough to do at work i put one together. I don't know if any of you are going to care enough to use it, mostly i'm just looking for advice on features i should add to it, inefficiencies in the design, stuff that's hard to understand, or whatever.
    This is it:
    *This catastrophe brought to you by SrA Meyerin.
    *Proximo Satis pro administatio.
    package awesomedate;
    //The following are imported for the toFormattedString(), toUtilDate(), toSQLDate, and toCalendar() methods, respectively.
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.GregorianCalendar;
    import java.sql.*;
    import java.util.TimeZone;
    *This class is designed to be the ultimate date object. It stores dates accurate to the millisecond, has the ability to do date
    *arithmetic (adding/subtracting days/months/whatever), date comparison, and date formatting. Also it can, at will, be used as any
    *of the other date objects in the standard java API.
    public class AwesomeDate
         *Milliseconds from the epoch. This field is where everything starts.
        private long millis;
         * The current year. This is the only aspect of the current date that is stored in addition to the milliseconds. Everything else
         * is calculated as needed.
        private int year;
        //The following six variables are fairly self explanatory. I'll explain them anyway.
         *Milliseconds in one non-leap year. This can be passed to the "adjustDate()" method
         * but mostly it is used to make my code more readable.
        public final static long MILLIS_IN_YEAR = 31536000000L;
         *Milliseconds in one leap year. This can be passed to the "adjustDate()" method
         * but mostly it is used to make my code more readable.
        public static final long MILLIS_IN_LEAP_YEAR = 31622400000L;
         *Milliseconds in one day. This can be passed to the "adjustDate()" method
         * but mostly it is used to make my code more readable.
        public static final long MILLIS_IN_DAY = 86400000;
         *Milliseconds in one hour. This can be passed to the "adjustDate()" method
         * but mostly it is used to make my code more readable.
        public static final long MILLIS_IN_HOUR = 3600000;
         *Milliseconds in one minute. This can be passed to the "adjustDate()" method
         * but mostly it is used to make my code more readable.
        public static final long MILLIS_IN_MINUTE = 60000;
         *Milliseconds in one second. This can be passed to the "adjustDate()" method
         * but mostly it is used to make my code more readable.
        public static final long MILLIS_IN_SECOND = 1000;
         *The number of days in each month.
        private int[] daysInMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
         *The timezone offset. GMT is 0, and the default, however, CST (where i live), is -6.
        private int timeZoneOffset = -6;
         *As the name would indicate, this is the number of milliseconds beyond 00:00 of jan 1 of the current year.
        private long millisAfterYear;
         *Basic constructor. Defaults to the current date and time. Works on Greenwich Mean Time, so it may seem off. To avoid this, multiply
         *add your time zone offset * MILLIS_IN_HOUR to the time in milliseconds.
        public AwesomeDate()
            setTimeInMillis(System.currentTimeMillis());
         *Fairly simple constructor. Sets time to the the number of milliseconds passed past the epoch.
        public AwesomeDate(long millis)
            setTimeInMillis(millis);
         *This constructor sets the date to the year/month/day passed.
        public AwesomeDate(int year, int month, int day)
            setDate(year, month, day);
         *This constructor sets the date time to the year/month/day/minute/hour/second passed.
        public AwesomeDate(int year, int month, int day, int hour, int minute, int second)
            setDate(year, month, day, hour, minute, second);
         *When you have the number of milliseconds, the first thing you must calculate is year. Because the number of milliseconds in a
         *year may vary, this is also the most difficult to calculate. This is the method that does it, though.
        private void setYearAfter1970()
            //I don't want to alter the actual number of milliseconds, so i make this variable and perform calculations on it.
            long theseMillis = this.millis;
            //Start at 1970 (the epoch) and work from there.
            year = 1970;
            long nextYear = MILLIS_IN_YEAR;
            //In this loop i subtract the number of millis in whatever year. The condition is if i have enough millis to make it through
                //another year.
            while (theseMillis >= nextYear)
                if (isLeapYear(year))
                    theseMillis = theseMillis - MILLIS_IN_LEAP_YEAR;
                    nextYear = MILLIS_IN_YEAR;
                else
                    theseMillis = theseMillis - MILLIS_IN_YEAR;
                    if (isLeapYear(year + 1))
                        nextYear = MILLIS_IN_LEAP_YEAR;
                year++;
            millisAfterYear = theseMillis;
            this.year = year;
         *Calculating the year from before 1970 must be done differently. It's pretty much just inverted.
        private void setYearBefore1970()
            long theseMillis = this.millis;
            year = 1970;
            long nextYear = MILLIS_IN_YEAR;
            while (theseMillis <= 0)
                if (isLeapYear(year))
                    theseMillis = theseMillis + MILLIS_IN_LEAP_YEAR;
                    nextYear = MILLIS_IN_YEAR;
                else
                    theseMillis = theseMillis + MILLIS_IN_YEAR;
                    if (isLeapYear(year - 1))
                        nextYear = MILLIS_IN_LEAP_YEAR;
                year--;
            millisAfterYear = theseMillis * -1;
            this.year = year;
         *Just what it sounds like. Pass it the number of milliseconds past the epoch and it will calculate the date based on that.
        public void setTimeInMillis(long millis)
            this.millis = millis;
            if (millis >= 0)
                setYearAfter1970();
            else
                setYearBefore1970();
         *Returns the number of milliseconds from the epoch.
        public long getTimeInMillis()
            return this.millis;
         *Returns the current year.
        public int getYear()
            return this.year;
         *Sets the date to 00:00 of Jan 1 of the passed year.
        public void setYear(int year)
            this.year = year;
            long theseMillis = 0;
            if (year > 1970)
                //Kind of like setYearAfter1970 method, except it's adding instead of subtracting. So actually it's the opposite.
                for (int cntr = 1970; cntr < this.year; cntr++)
                    if (isLeapYear(cntr))
                        theseMillis = theseMillis + MILLIS_IN_LEAP_YEAR;
                    else
                        theseMillis = theseMillis + MILLIS_IN_YEAR;
            else
                for (int cntr = 1970; cntr > this.year; cntr--)
                    if (isLeapYear(cntr))
                        theseMillis = theseMillis - MILLIS_IN_LEAP_YEAR;
                    else
                        theseMillis = theseMillis - MILLIS_IN_YEAR;
            //On a leap year there are 29 days in February. If not, there's 28.
            if (isLeapYear(year))
                daysInMonth[1] = 29;
            else
                daysInMonth[1] = 28;
            //This variable helps me calculate denominations of time that are below year.
            millisAfterYear = 0;
            setTimeInMillis(theseMillis);
         *Sets the month to the one that you passed, 0 being January and 11 being December.
        public void setMonth(int month)
            if (month < 0 || month > 11)
                throw new ArrayIndexOutOfBoundsException(month);
            long theseMillis = getTimeInMillis();
            int days = 0;
            setYear(this.year);
            if (getTimeInMillis() > 0)
                theseMillis = theseMillis - getTimeInMillis();
            else
                theseMillis = theseMillis + getTimeInMillis();
            for (int cntr = 0; cntr < month; cntr++)
                days = days + daysInMonth[cntr];
            millisAfterYear = days * MILLIS_IN_DAY + 1;
            setTimeInMillis(getTimeInMillis() + millisAfterYear);
         *Returns the month stored in this object. With this object 0 represents January and 11 represents December.
        public int getMonth()
            long theseMillis = millisAfterYear;
            int cntr = 0;
            while (theseMillis > (MILLIS_IN_DAY * daysInMonth[cntr]))
                theseMillis = theseMillis - MILLIS_IN_DAY * daysInMonth[cntr];
                cntr++;
            return cntr;
         *Set the day of month to the one passed.
        public void setDayOfMonth(int day)
            if (day < 1 || day > daysInMonth[getMonth()])
                throw new ArrayIndexOutOfBoundsException(day);
            setMonth(getMonth());
            //Internally, this actually works starting at zero, however to anyone using this class it appears to start at 1. Therefore
                //i must subtract one here.
            long addMillis = MILLIS_IN_DAY * (day - 1);
            millisAfterYear = millisAfterYear + addMillis;
            setTimeInMillis(getTimeInMillis() + addMillis + 1);
         *Returns the day of month.
        public int getDayOfMonth()
            int days = (int)(millisAfterYear / MILLIS_IN_DAY);
            int cntr = 0;
            while (days >= daysInMonth[cntr])
                days = days - daysInMonth[cntr];
                cntr++;
            //Internally this class stores dates starting at zero, but i want it to look like it starts at 1.
            return days + 1;
         *Sets the time to the currently selected day at the passed hour on the hour. uses 24 hour clock.
        public void setHour(int hour)
            if (hour < 0 || hour > 23)
                throw new ArrayIndexOutOfBoundsException(hour);
            setDayOfMonth(getDayOfMonth());
            long addMillis = MILLIS_IN_HOUR * hour;
            millisAfterYear = millisAfterYear + addMillis;
            setTimeInMillis(getTimeInMillis() + addMillis);
         *Returns the hour (but not how many minutes past the hour).
        public int getHour()
            long millisAfterDay = millisAfterYear % MILLIS_IN_DAY;
            return (int)(millisAfterDay / MILLIS_IN_HOUR);
         *Set the minutes past the hour. Works 0-59.
        public void setMinute(int minute)
            if (minute < 0 || minute > 59)
                throw new ArrayIndexOutOfBoundsException(minute);
            setHour(getHour());
            long addMillis = MILLIS_IN_MINUTE * minute;
            millisAfterYear = millisAfterYear + addMillis;
            setTimeInMillis(getTimeInMillis() + addMillis);
         *Returns the minutes past the hour, 0-59.
        public int getMinute()
            long millisAfterHour = millisAfterYear % MILLIS_IN_HOUR;
            return (int)(millisAfterHour / MILLIS_IN_MINUTE);
         *Sets the seconds past the minute, 0-59.
        public void setSecond(int second)
            if (second < 0 || second > 59)
                throw new ArrayIndexOutOfBoundsException(second);
            setMinute(getMinute());
            long addMillis = MILLIS_IN_SECOND * second;
            millisAfterYear = millisAfterYear + addMillis;
            setTimeInMillis(getTimeInMillis() + addMillis);
         *Returns the seconds past the minute, 0-59.
        public int getSecond()
            long millisAfterMinute = millisAfterYear % MILLIS_IN_MINUTE;
            return (int)(millisAfterMinute / MILLIS_IN_SECOND);
         *The more commonly seen set method of other date objects. Sets the date/time to 00:00 of the year/month/day passed. Convenience method
         *for setDate(int year, int month, int day, int hour, int minute, int second).
        public void setDate(int year, int month, int day)
            setDate(year, month, day, 0 , 0 , 0);
         *Sets every date/time field.
        public void setDate(int year, int month, int day, int hour, int minute, int second)
            setYear(year);
            setMonth(month);
            setDayOfMonth(day);
            setHour(hour);
            setMinute(minute);
            setSecond(second);
         *Returns yes if the stored date is a leap year. A leap year is every year that is divisible by four unless it is divisible by 100
         *unless it is also divisible by 400.
        public boolean isLeapYear()
            return isLeapYear(this.year);
         *For internal use. Returns if the passed year meets the criteria for a leap year.
        private boolean isLeapYear(int year)
            boolean leapYear = false;
            if (year % 4 == 0)
                if (year % 100 != 0)
                    leapYear = true;
                else if (year % 400 == 0)
                    leapYear = true;
            return leapYear;
         *Returns the difference in milliseconds between the time stored in this object and the millis passed to this method.
        public long getDifferenceInMillis(long millis)
            return getTimeInMillis() - millis;
         *Returns the difference in milliseconds between this date and the date passed to this method.
        public long getDifferenceInMillis(AwesomeDate otherDate)
            return getDifferenceInMillis(otherDate.getTimeInMillis());
         *Designed to be a wrapper method for the getDifferenceInMillis method. This method changes millis into years/days/whatever. Pass
         *the number of milliseconds you have to convert in the first parameter. The second parameter should be the type of denomination you
         *want (year, day, whatever). Use the MILLIS_IN_* fields associated with this object. Also bear in mind when workin with years that
         *some years are leap years, so in extreme cases of differences of 365+ years you may gain/lose a year.
        public static int toGreaterDenom(long millis, long denom)
            return (int)(millis / denom);
         * The first argument is how many of whatever (days, months, years, etc.) to add (use negative numbers to subtract). For the second
         * argument pass one of the MILLIS_IN_* fields. Thus, to add two hours would be
         * <code>
         *      AwesomeDate.adjustDate(2, AwesomeDate.MILLIS_IN_HOUR);
         * </code>
        public void adjustDate(int amount, long typeMillis)
            setTimeInMillis(this.millis + amount * typeMillis);
         *Returns an object of type java.util.Date set to the date/time stored here.
        public java.util.Date toUtilDate()
            long offset = TimeZone.getDefault().getRawOffset();
            return new java.util.Date(getTimeInMillis() +  -1 * offset);
    //        return new java.util.Date(getTimeInMillis());
         *Returns an object of type GregorianCalendar set to the date/time stored here.
        public GregorianCalendar toGregorianCalendar()
            long offset = TimeZone.getDefault().getRawOffset();
            GregorianCalendar cal = new GregorianCalendar();
            cal.setTimeInMillis(getTimeInMillis() - offset);
            return cal;
         *Returns an object of type java.sql.Date set to the date/time stored here.
        public java.sql.Date toSQLDate()
            long offset = TimeZone.getDefault().getRawOffset();
            return new java.sql.Date(getTimeInMillis() - offset);
        /** Format the date  using the string that you pass. Works just like the SimpleDateFormat object. Infact, it uses one! Heres
         *how it works:
         *Letter  Date or Time Component  Presentation  Examples  <br>
         *G  Era designator  Text  AD  <br>
         *y  Year  Year  1996; 96  <br>
         *M  Month in year  Month  July; Jul; 07<br> 
         *w  Week in year  Number  27  <br>
         *W  Week in month  Number  2  <br>
         *D  Day in year  Number  189  <br>
         *d  Day in month  Number  10  <br>
         *F  Day of week in month  Number  2<br> 
         *E  Day in week  Text  Tuesday; Tue  <br>
         *a  Am/pm marker  Text  PM  <br>
         *H  Hour in day (0-23)  Number  0<br> 
         *k  Hour in day (1-24)  Number  24  <br>
         *K  Hour in am/pm (0-11)  Number  0  <br>
         *h  Hour in am/pm (1-12)  Number  12  <br>
         *m  Minute in hour  Number  30  <br>
         *s  Second in minute  Number  55  <br>
         *S  Millisecond  Number  978  <br>
         *z  Time zone  General time zone  Pacific Standard Time; PST; GMT-08:00<br> 
         *Z  Time zone  RFC 822 time zone  -0800  <br>
        public String toFormattedString(String format)
            SimpleDateFormat formattage = new SimpleDateFormat(format);
            return formattage.format(toUtilDate());
         *I overrode the toString method. Now it tells everyone how awesome my AwesomeDate is.
        public String toString()
            String output = "John's Awesome Date!";
            output = output + " Millis: " + getTimeInMillis();
            output = output + " Year: " + getYear();
            output = output + " Month: " + getMonth();
            output = output + " Date: " + getDayOfMonth();
            output = output + " Time: ";
            if (getHour() < 10)
                output = output + "0" + getHour();
            else
                output = output + getHour();
            if (getMinute() < 10)
                output = output + "0" + getMinute();
            else
                output = output + getMinute();
            output = output + " Seconds: " + getSecond();
            return output;
        public static void main(String[] psvm)
            AwesomeDate blah = new AwesomeDate();
            GregorianCalendar blah1 = new GregorianCalendar();
            GregorianCalendar blah2 = new GregorianCalendar();
    }

    The reason Callendar is so complicated is that it is trying to solve a very complicated problem.
    You don't appear to support leap seconds (of which there can be upto 2 in any time interval)
    http://www.timeanddate.com/time/leapseconds.html
    Some of your code will not work for large dates very well (seems to iterate over the years). Try using your date class for astronomical or geological calculations. them big numbers will make your code slow at the moment.
    You don't seem to support timezones or transitory offsets (BST vs GMT). You most definately don't handle changes to timezone offsets that have occured in the past or historical daylight savings time offsets (they have not always been the same)
    The difference between two calendars is a "duration" a duration means nothing unless it is applied to a caledar/date (although you may be able to get away with it if the duration is always stored in millis)

  • Liquid data type updates

    Hi everyone,
    With the next release (to go out on Monday) we're adding proper date format support in liquid for all modules. Besides all the improvements and additions made available with this release, one important note, which requires you to do some updates after the release, is that we're breaking backwards compatibility for liquid date tags by outputting the dates in ISO 8601 format ("yyyy-MM-ddTHH:mm:ss") instead of current format(“yyyy-MM-dd”).
    Here is a brief overview of the changes:
    All module fields which represent date or date times are now passed to Liquid as date time objects (previously they were passed as strings). This brings the following benefits:
    Comparison between date time objects works correctly
    It is possible to compute the difference between two date time objects using the minus filter. Example: {% assign dateDiff = Globals.Site.DateNow| minus: myDate %}
    We added the means for obtaining the current date time: Globals.site.dateNow. The returned date is in the site’s time zone.
    By default, when no filter is applied, all date variables will be output in the following ISO 8601 format: “yyyy-MM-ddTHH:mm:ss”. For example {{ myDate }} would output something similar to: “2014-12-12T07:19:49”. (Note: this is a backwards compatibility breaking change, as previously we outputted dates using the following format: “yyyy-MM-dd”. The breaking change only affects Liquid tags). Following the release, you should update your sites using the provided date filters to format the dates as you need.
    The output of date time variables can be formatted using the following filters:
    date (with no parameters)– displays a nice to read string representing just the date part from the date time variable. The date is formatted in the site’s culture. This compatible with the way older BC tags display dates. For example {{ myDate | date }}, in the English US culture will output a string similar to: “12-Dec-2014”.
    datetime (new filter) – displays a nice to read string of the date time variable using the site’s culture. This compatible with the way older BC tags display date time. For example {{ myDate | datetime }}, in the English US culture will output a string similar to: “12-Dec-2014”.
    date “format” (existing filter, nothing updated, mentioned here just for consistency) – displays the date in the site’s culture using a format specified by the format variable. The list with the available formats is available here: http://msdn.microsoft.com/en-us/library/8kb3ddd4%28v=vs.110%29.aspx. Note that the date filter can also be used to format objects that result as a difference between two date time objects, however, in this case the format string will respect a different set of rules as defined here: http://msdn.microsoft.com/en-us/library/ee372287%28v=vs.110%29.aspx. The following example demonstrates how to display just the number of days in the difference between two dates: {{ Globals.Site.DateNow| minus: myDate| date: "%d" }}
    We added the Convert filter which can be used for converting variables to a certain type. The syntax is: variable | convert: “type”. Below are the values supported by the type parameter:
    “date” – converts a variable to a date time instance. We only support the following formats for strings that are converted to date time: “yyyy-MM-ddTHH:mm:ss” and “yyyy-MM-dd”.
    “number” – converts a variable to a number instance. If converting from string, only period “.” is supported as a decimal separator. This filter will probably be most useful when trying to convert GET query parameters: {% assign pageNumber = Globals.get.pageNumber | convert: “number” %}. The previous example assumes that URL that loaded the page contains a parameter named pageNumber. The convert numeric filter is an alternative to the rather hack-ish approach of converting to numbers using mathematical operators: {% assign myNumber = variable | plus: 0 }. Please note that it is not recommended to use the convert numeric filter just to assign numeric constants. For example, this approach is not recommended: {% assign myNumber = “3.14” | convert: “number” %}. Use the following approach instead: {% assign myNumber = 3.14 %} (note the lack of quotes around 3.14 in the second example).
    “boolean” – converts a variable to a boolean instance. Please note, that just as it is the case with numerics, it is not recommended to use the “boolean” filter for declaring a boolean constant. For example this is not recommended: {% assign myBool = “false” | convert: “boolean” %}. Use the following syntax instead: {% assign myBool = false %}
    “string” – converts a variable to its string representation.
    We added implicit casting to the most relevant type in comparisons and inside filters representing mathematical operations (plus, minus, times, divide, modulo). With implicit casting, if one of the two operands is of type string and the other is of a different type (for example numeric or date time), we will attempt to convert the string operand to the type of the other. The conversion will fail if the string is not in an appropriate format for the type it is converted to (same rules as in the Convert filter are applied). In comparisons, if the implicit casting fails, the comparison is made with both operands converted to strings. Additional notes:
    Implicit casting allows using date time literals directly in comparisons if the other operand is of date time type. For example, this will work correctly since "2015-01"15" will automatically be converted to date time before making the comparison: {% if myDate > "2015-01-15" %}Some message{% endif %}
    Date parts obtained using the date filter can be used directly in comparisons with numerics. For example:
             {% assign daysDiff = Globals.Site.DateNow| minus: myDate| date: "%d" %}
              {% if daysDiff < 10 %}
                A message
              {% endif %}
    With the implementation of implicit casting we also fixed some rather funny bugs related to comparisons and mathematical operations. For example, previously, 5 < 5.5 was evaluated as false, but 5.5 > 5 was evaluated as true. Also the result of 5| plus: 5.5 was 10, but the result of 5.5| plus: 5 was 10.5 (now 10.5 is the result of both operations, as expected).
    As a potential caveat, note that implicit casting will bring the operands to the relevant type only if one of them is actually of that type. If both operands are of type string, the comparison is made as of between strings. This means that following condition is evaluated as false {% if "3" < "15" %}, because as a string "15" is smaller than "3".
    Implicit casting from string to numeric only works if the string represents just a numeric. If the string contains additional characters, like a currency symbol, the conversion will fail. For example, this will not work correctly {% "$15" < 20 %}. Our goal, in the next releases, is to update all modules containing price related tags to have them in plain numeric format.
    We added the following filters for easily formatting numeric values representing prices.
    number - displays numbers with a fixed number of two decimals using the decimal separator appropriate to the site's culture. For example, in the English US culture, {{ 99| number }} will display 99.00
    currency - displays numbers in the same way as number but also inserts the currency symbol at the beginning of the returned value. The currency symbol respects the site's culture. For example, in the English US culture, {{ 99| currency }} will display $99.00
    In the next release or releases, we're going to focus on fixing the remaining data types for modules.
    Cristinel

    Liam, the server date isn't helpful for converting timezones. We would need a direct date filter. With a filter for UTC and one for the user we should be able to do quite a bit from there.
    The most powerful things that could be implemented for date time are the following:
    • moment.js and Moment Timezone built into the filters.
    • the ability to add time info into date time fields
    But I know that's a tall order.

Maybe you are looking for

  • When writing a new message my blinking cursor is gone from the body of the message, where did it go?

    When i want to write a new message in Thunderbird, my blinking cursor is there in the subject line and in the email address line but not in the body of the message where i want to Type my message. Where did it go and How do i turn it back on?

  • Problems Importing into Address Book

    Trying to import my address book from a vcf file. I get the following error: Are you sure you want to add 1511 cards to your address book? There were problems importing. My address book file has 2308 cards, not 1511. Any suggestion

  • Best Practice AV set up on SAP Servers

    Hi, Has anyone come across or aware of any best practice guidelines for AV setup on SAP servers, for example, which files/drives should you exclude and configuration tuning/reg-edits required. We have McAfee as our standard AV and we do use the HIPS

  • Product Comparison Application

    Hi All, I attended an Abobe 'Fully Loaded Tour' today and during the Flash session, the presenter showed an application - in this case on a digital camera site where thumbnails of all cameras were initially shown. The user could then either move slid

  • Qosmio G20 - How to install with one single HDD and without RAID?

    I want to set up Qosimo G20 new with Windows XP 32. I bought a new harddisk and put it into slot 1. I would like to run it without any RAID (so slot 2 is empty) XP installation CD did not discover the HD I entered BIOS to see if the HD was there - Th