Numbers of hours in two different dates

I have two days and it is in df = new SimpleDateFormat("yyyyMMddHHmmss") format.
start date is 20041203180000 ( year, month, day of month, hours, minutes )
end date is 20041204050000
How do I calculate the number of hours between those two days.
Thanks

I think this would work (I was bored)...
public static int getCountBetween(Date d1, Date d2, int field) {
   if(d1 == null || d2 == null) {
      throw new NullPointerException();
   if(d1 == d2 || d1.equals(d2)) {
      return 0;
   if(d1.after(d2)) {
      Date dx = d1;
      d1 = d2;
      d2 = dx;
   Calendar c1 = new GregorianCalendar();
   c1.setTime(d1);
   Calendar c2 = new GregorianCalendar();
   c2.setTime(d2);
   int count = 0;
   while(c1.before(c2)) {
      c1.roll(field, 1);
      count++;
   return count;
}That's pretty generic,... field would be Calendar.MONTH or Calendar.HOUR_OF_DAY or whatever field. It's probably not as quick as other ways...

Similar Messages

  • How to process reports with two different date fields

    Morning all,
    This question is somewhat similar to what I asked few days back. I created two different reports for two different departments (Credit Control and Free of Charge Control).
    These two reports pull data from two different date fields and has different status check ups.
    Few days back my director requested me if he can have both reports in one report. That is when I asked question from all of you regarding two reports.
    Anyhow, that was created by implementing two sub reports however, the director asked me to combine the two different reports into one in such a way that the output records should be added up with each other hence one single report with all combined data of Credit Control and Free of Charges (not two sub reports in one report).
    The problem here which I am getting is that, both reports uses two different date fields. I can live with two different statuses as that can be easily done within formula/RT however how to create a report with Report Selection Formula condition which looks in both date fields and produces results accordingly?
    I have tried this by not putting any condition in report selection formula and ran the report, it produced total results from past 6 years.
    Any ideas how to produce combined report which has two different date fields?
    Many thanks in advance
    Regards
    Jehanzeb
    What I

    Charliy,
    No the both dates are from two different databases, tables and fields. The Credit date field is from KLAB database under max table where as the FOC date field is from SAE database under maxmast table. Klab date is under credit2 table where as foc date is under order header table.
    So its more like this:
    Klab->Max-Credit2--->Credit_date
    Sae->Maxmast->Order_header---Date entered.
    two dates totally different tables, dbs
    however, I will try your idea too and see if that works.
    Regards
    Jehanzeb

  • Need suggestion for ISE distributed deployment model in two different data centers along with public certificate for HTTPS

    Hi Experts,
    I am bit confused about ISE distributed deployment model .
    I have two data centers one is DC & other one is as a DR I have  requirement of guest access service implementation using CWA and get public certificate for HTTPS to avoid certificate error on client devices :
    how do i deploy ISE persona for HA in this two data centers
    After reading cisco doc , understood that we can have two PAN ( Primary in DC  & Secondary in DR ) like wise for MnT (Monitoring will be as same as PAN ) however I can have 5 PSN running in secondary i.e. in DR ISE however I have confusion about HA for PSN .. since we have all PSN in secondary , it would not work for HA if it fails
    Can anybody suggest me the best deployment solution for this scenario ?
    Another doubt about public certificate :
     Public Certificate: The ISE domain must be a registered or part of a registered domain name on the Internet. for that I need Domain name being used from customer .
    Please do correct me if I am wrong about certificate understanding :
    since Guest will be the outside users , we can not use certificate from internal CA , we need to get the certificate from service provider and install the same in both the ISE servers
    Can anybody explain the procedure to opt the public certificate for HTTPS from service provider ? And how do i install it in both the ISE servers ?

    Hi there. Let me try answering your questions:
    PSN HA: The PSNs are not configured as "primary" or "secondary" inside your ISE deployment. They are just PSN nodes as far as ISE is concerned. Instead, inside your NADs (In your case WLCs) you can specify which PSN is primary, which one is secondary, etc. You can accomplish this by:
    1. Defining all PSN nodes as AAA radius servers inside the WLC
    2. Then under the SSID > AAA Servers Tab, you can list the AAA servers in the order that you prefer. As a result, the WLC will always use the first server listed until that server fails/gets reloaded, etc. 
    3. As a result, you can have one WLC or SSID prefer PSN server A (located in primary DC) while a second WLC or SSID prefer PSN server B (located in backup DC)
    Last but not the least, you could also place PSNs behind a load balancer and that way the traffic would be equally distributed between multiple PSNs. However, the PSN nodes must be Layer 2 adjacent, which is probably not the case if they are located in two different Data Centers
    Certificates: Yes, you would want to get a public certificate to service the guest portal. Getting a public/well known certificate would ensure that most devices out there would trust the CA that signed your ISE certificate. For instance, VeriSign, GoDaddy, Entrust are some of the ones out there that would work just fine. On the other hand, if you use a certificate that was signed by your internal CA, then things would be fine for your internal endpoints that trust your internal CA but for any outsiders (Guests, contractors, etc) that do not trust and do not know who your internal CA is would get a certificate error when being redirected to the ISE guest portal. This in general is only a "cosmetic" issue and if the users click "continue" and add your CA as a trusted authority, the guest page would load and the session would work. However, most users out there would not feel safe to proceed and you will most likely get a lot of calls to your helpdesk :)
    I hope this helps!
    Thank you for rating helpful posts!

  • How do I calculate days from two different dates?

    Hi all,
    How do I calculate days from two different dates?
    my requirement is to pass the number of days to target field from two dates.
    Current date :  14/04/2010
    Standard date: 01/01/1957 is the standard = day 0
    Is it possible in graphical mapping with out  udf?
    Plz help me on this I have donu2019t have much knowledge on JAVA.
    Thanks

    Hi Yadav,
    Probably this is not the correct forum for XI / PI .
    You can post the same to...
    Process Integration (PI) & SOA Middleware
    Hope this helps.
    Regards
    Raj

  • How do I calculate days from two different dates in XI/PI?

    Hi all,
    How do I calculate days from two different dates in XI/PI?
    my requirement is to pass the number of days to target field from two dates.
    Current date : 14/04/2010
    Standard date: 01/01/1957 is the standard = day 0
    Is it possible in graphical mapping with out udf?
    Plz help me on this I have donu2019t have much knowledge on JAVA.
    Thanks

    Hi Yadav,
    Probably this is not the correct forum for XI / PI .
    You can post the same to...
    Process Integration (PI) & SOA Middleware
    Hope this helps.
    Regards
    Raj

  • How to calculate AGE from two different date fields

    hi
    I need to calculate AGE from two different date fields.
    Can some help me how to do, when i try to do substraction formula it is showing error.
    Thank You
    Manu

    Manu wrote:
    Hi
    Both fields are in date format only, i need to calculate no . of days between two different dates
    Thanks
    ManuThe reason for the question about the format of the column is because the simplest solution only works on DATE columns. Others have mentioned this here, but if you want the difference between two date fields, you can use this formula:
    TIMESTAMPDIFF(SQL_TSI_DAY, date_column1, date_column2)
    The above being said, you still didn't tell me what you did, or what error message you received. So again, if the above formula didn't work, what did you do? Where did you put the formula? What was the exact syntax you used? What was the error message you got?
    Please don't make us work more than we need to. Answer all the questions in your next post. Thanks.

  • Plotting x and y axis from two different data

    Hi everyone,
    I've just started using LabView on my new job. My new task is to create a VI to display a plot an XY graph from two data. How do I actually assign the two different data (X and Y axis resepctively)and plot them out on a same graph??
    Please help me out... my job is on the line!

    Other may post an example for you.
    I will tell how to find this and many other answers.
    Do a "Find Examples" from either the LV open screen or from the Help drop down.
    LV ships with examples that demonstrate almost every basic operation.
    One of the big benifits of these examples is that they work! If they do not, NI is interested in finding which ones do not.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Report using two different data sources won't work.

    I'm trying to build a report that shows information from a production table and an archive table.
    Tables are in different databases, which are defined as their own Data Sources in Publisher.
    Two data sets containing the same query but using different Data Sources are defined in the Data Model.
    When selecting option 'Concatenated SQL Data Source' the report never completes.
    If any of the two Data Sets is selected as the Main Data Set, the report shows information related to that source only.
    Any hints on how to make this work would be appreciated.
    Thanks.
    ccastillo

    More details on this issue:
    The production database has a synonym pointing to the archive database. I build a query using a UNION ALL statement linking both tables.
    For the same set of parameters, this query completes in a couple of minutes outside BI Publisher, but never ends (I cancel after an hour) inside Publisher.
    Is there any special considerations for the use of synonyms inside Publisher?

  • Comapre 2 same channels from two different dat filea

    Hi ,
    I want to compare the wave forms of two same channels names (in my sample data which is in attachment, the same channel names are S1KNSLLE00H3DSZP) from different dat  file(S2100044 and S2100041) .
    Load the 2 dat files from navigator.
    Come to report and open two 2d axis systems to see the wave forms of two different channels ( Like in attachment result.jpg)
    I need an autosequence to do the same for all the channels for 2 dat files automatically.
    Attachments:
    cmp.zip ‏1967 KB
    result.JPG ‏158 KB

    Hi RSH,
    I appreciate you posting 2 data files and the jpg, but I'm afraid I still have lots of questions before I can advise you.  You sent 2 *.dat files which each had 1 channel in them named "Data", which is different from your email text and the jpg you posted.  Will your data sets typically have many channels in them?  Your posted *.dat files had no time channel and the "Data" channel was not a waveform channel, yet the 2 different "Data" channels were different lengths.  Do you want to plot your channels vs. the array index all the time (as is shown in your jpg)?
    Do you want to have N sheets in REPORT, one for each channel?  Why don't you want to have both "S1KNSLLE00H3DSZP" channels as curves with different colors on the same graph-- wouldn't that make it easier to compare them?
    When you drag over the data channel onto a REPORT graph, you will get a reference like "[1]/Data" or "[2]/Data", which is exactly what you want to compare the "Data" channel from 2 arbitrary data files (note that the file name does not show up in the channel references).  So it seems to me that the REPORT layout you sent a jpg of already satisfies what you're asking us to create for you.  Why do you need a script at all?
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

  • Login Module validation against two different data sources

    Hi All,
    We have the following setup
    NW Portal 7.31
    Single stack
    We are in the process of implementing Employee Self Service 1.50 WDA.
    And as part of the requirement , we have implemented LDAP as the UME DataSource.
    So, employees log into the portal using the LAN ID and Windows password  and are authenticated using the Logon ticket.
    Now the client has come up with a requirement to have all German employees login with their ECC user id and password.
    NOTE: ECC User ID and LAN IDs are the same, but the passwords are different.
    a) Is it possible to use two UME data sources for logon validation.
    b) Is customization of the Login module needed for this scenario?? If Yes, what components need to customized?
    c) What is the best approach to handle this requirement?
    Thanks.
    Regards,
    Raj

    check this link if it provide any helpful info:
    User Mappings in the Authentication Framework of SAP NetWeaver Application Server (AS) Java - Security and Identity Mana…
    Also you can search around creating a custom login module for authenticating useres against ECC ,if its possible you need to plugin the custom login module in your authentication stack along with the applicable flag and order so that if user authentication failed at ldap level then the control should go to authenticate it against the ECCcustom login module and logon ticket should be generated in both the cases.

  • Two different dates on a same fact table.

    I use OBIEE and I got some difficulties with the times dimensions and the function AGO because I used two differents dates for my measure.
    My fact table:
    Ordered     Delivered Amount
    1/1/2009     2/1/2009     20000
    1/1/2009     3/1/2009     10000
    *2/1/2009* 2/1/2009     50000
    *2/1/2009* 3/1/2009     50000
    1/1/2010     2/1/2010     25000
    1/1/2010     3/1/2010     20000
    1/1/2010     2/1/2010     20000
    1/1/2010     3/1/2010     15000
    I have two Times Dimensions (Ordered Times AND Delivered Times) and one fact table.
    I want to compare the delivered situation (Amount Qty) for the same ordered day last year
    I created a prompt with a date (ex.: Ordered date <=1/1/2010 AND Delivered date >=1/1/2010) and I want to compare one year ago with 1/1/2009 (Ordered Date situation…)
    I wish the results below:
    Delivered Month/Amount/Previous Amount Year Ago
    2/     45000/          20000
    3/     35000/          10000
    I got some problem cause I had the 100 000 in my previous year (Ago) and I don’t want it because it was ordered after 1/1/2009 (Previous year). I know that the ago function concerns the Sum of Amount by Delivered Date, Year -1 ...
    Does somebody has a solution for this ? Thank you
    Edited by: user8898885 on Feb 8, 2010 1:01 PM
    Edited by: user8898885 on Feb 8, 2010 1:05 PM
    Edited by: user8898885 on Feb 8, 2010 1:05 PM

    Ok, i created two facts table.
    But now, what's the way to know this distribution (Delivered date) for the period (Ordered date).
    Because, i got the sum of the amount by the deliverd date, and the sum for the ordered date AND i can't obtain the comparaison for the same period of ordered date.
    Example:
    Date Ordered || Date Delivered || Amount
    janv 1, 2010 || feb. 25 2010 || 40 000
    janv 5, 2011 || mar 23 2011 || 60 000
    I want to compare for the ordered date, the delivered distribution
    Promp = Janv. 2011
    Delivered || This year || Previous year
    Feb || 0 || 40 000
    March || 60 000 || 0
    That's my situation.
    i hope than the explication is correct. I think than 1 fact table with 2 time dimension (Alias) is the way to do. But you have parhaps a best practice.

  • Two Different Data Sources in EIS

    <p>Hi -</p><p> </p><p>Can we have 2 different Data Sources in the OLAP model.</p><p>Example:</p><p>We have our Fact table in Teradata and Dimension table inOracle.</p><p>Can we create a model with this kind of scenario?</p><p>WIll it be a maintenance nightmare if we do this?</p><p> </p><p>Any help would be greatly appreciated.</p><p> </p><p>Thanks,</p><p>Jeeva</p>

    Hi Jeeva,<BR><BR>Yes you can do this. I have models which use data from Oracle, SQL Server and also Text files! All you need is to setup the appropriate ODBC connections on the box that contains EIS then when you create your OLAP model, you add new data sources by clicking "Connections" then "Add Data Source"<BR><BR>Hope this helps.<BR><BR>Brian

  • Combining two different data warehouses

    i have a user who wants to combine data from 2 different data warehouses.  Can someone explain or provide instructions on how this can be done in BO Deski Reporter?
    Thanks.

    Hi-Create 2 data providers from the 2 different universes representing the data warehouses. After they are created go the data manager by clicking on View Data and then click the data provider. Make sure the Definition tab is open. Click the dimension/s you want to join in the other data provider (one at a time)  and click Link to..select the dimension in other data provider you want to join. Repeat for each dimensions you want to join in the other data provider.
    When creating a report the joined dimension can be placed in the report and dimensions from one data provider. Dimensions from the other data provider can be added by creating new detail variables pointin to the dimension.
    Any questions let me know and do award points if it works for you.
    Ashok

  • Open two Forms  Connecting Two different Data bases simultaneously.

    i am facing a problem for opening two forms in two different SAPB1 applications where it is connecting into two different databases.please send me a solution for this problem.

    Hi Hareen,
    What is your goal to design a form for connecting 2 databases in the same time?
    Thanks,
    Gordon

  • Open two Forms  Connecting Two different Data bases

    In The Same Company Two Different Places Open Same SAPB1 Application Connecting with Two different DataBases,Open both two forms same time.

    Hi Mai,
    you can always open multiple forms in a company.so if you want to open one form from Database 1 and Database 2 , then its okay. If  I did not answer your question correctly, then kindly explain your question in a more detailed way.
    Regards,
    Darius Gragasin

Maybe you are looking for

  • Adobe Reader version 7.1.0 will not install

    Hi all, I am bringing up a new Discovery server and working through the SAP Discovery System Quick Guide.  My question is that Adobe Reader version 7.0.9 is no longer available and version 7.1.0 will not launch. Has anyone seen an issue with this?  W

  • Downloading new photos - iPhoto doesn't work after upgrading to Yosemite

    Hello, Since I upgraded to Yosemite, iPhoto has stooped working after downloading photos from my Sd card. Some picutres downloaded are black while some others are ok, but in any case I have to restart my iMac because every apps running can't be used

  • EXPDP error - Help

    Good morning When I run expdp I got this error. My first expdp was fine but the second expdp I got the next error: Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE ORA-39171: Job is experiencing a resumable wait. ORA-01691: unable to extend

  • Can Canon MP600R scan wirelessly?

    I am totally confused about my all-in-one. Before Lion I used it successfully for printing and scanning, both using USB and Ethernet connection. I can't recollect using it wirelessly. I'd like to use it wirelessly now, but I have problems. The printe

  • Want to know about SRM

    Hi ALL I'm working as a MM consultant right now  and  very much interested to  learn SAP SRM through this Forum. Can any one provide me the full details about SRM like Introduction , config steps , architecture and other details if any. Awaiting for