Using two dates to find the age...

Hello

I need to find the age of a person the DOB entered into service.  the age may be days or years depending on when the person was born.

If the person was born is less than a year, so I should be able to calculate the number of days on the other, it should be over the years.

I can't find the right way to do it.  I tried like this but its does not work as it should:

todaysDate long = (new Date()) .getTime ();
long date of birth = dobDateField.getDate ();

long dateDiff = todaysDate - date of birth;

multiply a day with 365 days (ignore the leap year for now)
length of year = DateTimeUtilities.ONEDAY * 365;

If (dateDiff< year)="">
int NoOfDays = (int) (dateDiff / DateTimeUtilities.ONEDAY);
ageEditField.setText (String.valueOf (NoOfDays) + "D");
 
} else {}
int NoOfYears = (int) (dateDiff/year);
ageEditField.setText (String.valueOf (NoOfYears));
}

Help, please...

int age = (diff / (1000 * 60 * 60 * 24));
int years = 0;

if( age >= 365 ) {
   years = age / 365;
}

if( years > 0 ) {
 // use years
} else {
 // use days
}

Something like that.

Tags: BlackBerry Developers

Similar Questions

  • How to compare two dates and find exactly

    How to compare two dates and find the exact age of the person, no one could be an age of child 2 days or a month, or other.

    I'd really appreciate if someone help o

    Concerning

    After spending 2 hours, I go out with a solution by myself, how ever the function can be customize to check if the user enters date right.

    function findAge(subjectName,fromdate, todate) {
        console.log("findAge(fromdate, todate) is called now "+subjectName+"-->"+fromdate+"-->"+todate);
        if(todate) todate= new Date(todate);
        else todate= new Date();
    
        var age= [], fromdate= new Date(fromdate),
        y= [todate.getFullYear(), fromdate.getFullYear()],
        ydiff= y[0]-y[1],
        m= [todate.getMonth(), fromdate.getMonth()],
        mdiff= m[0]-m[1],
        d= [todate.getDate(), fromdate.getDate()],
        ddiff= d[0]-d[1];
    
        if(mdiff < 0 || (mdiff=== 0 && ddiff<0))--ydiff;
        if(mdiff<0) mdiff+= 11;
        if(ddiff<0){
            fromdate.setMonth(m[1]+1, 0);
            ddiff= fromdate.getDate()-d[1]+d[0];
            --mdiff;
        }
        if(ydiff> 0) age.push(ydiff+ ' year'+(ydiff> 1? 's ':' '));
        if(mdiff> 0) age.push(mdiff+ ' month'+(mdiff> 1? 's':''));
        if(ddiff> 0) age.push(ddiff+ ' day'+(ddiff> 1? 's':''));
        if(age.length>1) age.splice(age.length-1,0,' and ');
        console.log("===============================");
        console.log("Subject age is = "+age.join(''));
        console.log(" age Day = "+ddiff);
        console.log(" age Month = "+mdiff);
        console.log(" age Year = "+ydiff);
        console.log("===============================");
        var subjectAGE =  age.join('');
    
    }
    

    peardox Thanks for the reply

  • I can't use windwo Defender, my pc show if you use another application to find the unwanted malicious software, use action center to cheack app status

    "I can't use winddow Defender, my pc show' If you use another application to find the unwanted malicious software, use action center to cheack app status."
    Please help me solve. Thank you

    Hello

    If you use Norton, AVG, Avira, Microsoft Security Essentials, McAfee, etc. the default action is for Windows Defender must be disabled, that these AntiVirus programs have their own Antispyware Applications.

    There is nothing to worry.

    Using both programs at the same time can cause system conflicts, etc.

    If you are using one of the above AntiVirus programs, this Information from David O - Support Engineer shows you how to manually enable Windows Defender (disregard information from uninstalling; not possible in Vista):

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_vista-security/how-do-i-manually-start-Windows-Defender-in-Vista/dab845b2-9ba5-47F3-9518-c4c6781e7d5b

    "Go to start, Control Panel, Administrative Tools, Services. Look for Windows Defender.

    Right click and select Properties , ensure that Startup Type is automatic.

    Once modified, click apply and OK.

    Quit and restart your computer. Check the back take the same path to confirm that Windows Defender has started"

    .

    If you want to have additional protection against malware using the version FREE of Malwarebytes AntiMalware:

    http://www.Malwarebytes.org/products/malwarebytes_free

    And for now, change startup Vista programs without using Defender, use one of these methods:

    "How to use MSCONFIG in Windows Vista"

    http://netsquirrel.com/Msconfig/msconfig_vista.html

    Or the program Autoruns for FREE:

    "V11.21 Autoruns for Windows"

    http://TechNet.Microsoft.com/en-us/sysinternals/bb963902

    See you soon.

  • Is it possible to use two different computers with the same adobe - ID and the same adobe license?

    Is it possible to use two different computers with the same adobe - ID and the same adobe license?

    Hi Morten,

    Yes, you can have your subscription or your license installed on two different computers with the same adobe id, however use one at a time.

    Please let us know if you have any questions, more about it.

  • How to find the age of a child and snapshot number snapshot for a virtual machine.

    Hi all

    How to find the age of a snapshot for a virtual machine child count and snapshot.

    This code snippet should help... Assuming that you have the following entries:

    VM (VC:VirtualMachine)

    snapshot (VC:VirtualMachineSnapshot)

    System.log("====== Snapshot details for VM: "+snapshot.config.name+" ======");
    var snapshotTrees = vm.snapshot.rootSnapshotList;
    System.log("Snapshot Tree Count: "+snapshotTrees.length);
    for each (snapshotTree in snapshotTrees){
        showSnapshotInfo(snapshotTree, snapshot);
    }
    
    function showSnapshotInfo(snapshotTree, selectedSnapshot){
        if(selectedSnapshot == snapshotTree.snapshot){
            System.log("====================");
            System.log("Name: "+snapshotTree.name);
            System.log("Id: "+snapshotTree.id);
            System.log("Description: "+snapshotTree.description);
            System.log("createTime: "+snapshotTree.createTime);
            System.log("quiesced: "+snapshotTree.quiesced);
            System.log("replaySupported: "+snapshotTree.replaySupported);
            System.log("backupManifest: "+snapshotTree.backupManifest);
            System.log("snapshot id: "+snapshotTree.snapshot.id);
            System.log("state: "+snapshotTree.state.value);
            var childSnapshotList = snapshotTree.childSnapshotList;
            if(childSnapshotList != null){
                System.log("childSnapshotList length: "+snapshotTree.childSnapshotList.length);
            }
            System.log("");
        }
        if(snapshotTree.childSnapshotList != null){
            System.log("Children found: "+snapshotTree.childSnapshotList.length);
            for each (childSnapshotTree in snapshotTree.childSnapshotList){
                showSnapshotInfo(childSnapshotTree, selectedSnapshot);
            }
        }
    }
    

    During the passage of one of my virtual machines, here is an example of output I get:

    [2014-06-12 15:19:21.493] [I] Snapshot Tree Count: 1
    [2014-06-12 15:19:21.493] [I] ====================
    [2014-06-12 15:19:21.494] [I] Name: before upgrade to 5.0.1
    [2014-06-12 15:19:21.494] [I] Id: 31
    [2014-06-12 15:19:21.494] [I] Description:
    [2014-06-12 15:19:21.495] [I] createTime: Mon Mar 19 2012 13:48:57 GMT-0400 (EDT)
    [2014-06-12 15:19:21.495] [I] quiesced: false
    [2014-06-12 15:19:21.495] [I] replaySupported: null
    [2014-06-12 15:19:21.495] [I] backupManifest: null
    [2014-06-12 15:19:21.496] [I] snapshot id: snapshot-83
    [2014-06-12 15:19:21.496] [I] state: poweredOff
    [2014-06-12 15:19:21.496] [I] childSnapshotList length: 1
    [2014-06-12 15:19:21.496] [I]
    [2014-06-12 15:19:21.497] [I] ====================
    [2014-06-12 15:19:21.497] [I] Name: Before 5.1 upgrade
    [2014-06-12 15:19:21.497] [I] Id: 36
    [2014-06-12 15:19:21.497] [I] Description:
    [2014-06-12 15:19:21.498] [I] createTime: Fri Sep 21 2012 21:59:58 GMT-0400 (EDT)
    [2014-06-12 15:19:21.498] [I] quiesced: false
    [2014-06-12 15:19:21.498] [I] replaySupported: null
    [2014-06-12 15:19:21.498] [I] backupManifest: null
    [2014-06-12 15:19:21.499] [I] snapshot id: snapshot-84
    [2014-06-12 15:19:21.499] [I] state: poweredOff
    [2014-06-12 15:19:21.499] [I] childSnapshotList length: 1
    [2014-06-12 15:19:21.499] [I]
    [2014-06-12 15:19:21.500] [I] ====================
    [2014-06-12 15:19:21.500] [I] Name: Before Named Instance
    [2014-06-12 15:19:21.500] [I] Id: 37
    [2014-06-12 15:19:21.501] [I] Description:
    [2014-06-12 15:19:21.501] [I] createTime: Mon Nov 11 2013 13:40:46 GMT-0500 (EST)
    [2014-06-12 15:19:21.501] [I] quiesced: false
    [2014-06-12 15:19:21.501] [I] replaySupported: null
    [2014-06-12 15:19:21.502] [I] backupManifest: null
    [2014-06-12 15:19:21.502] [I] snapshot id: snapshot-236
    [2014-06-12 15:19:21.502] [I] state: poweredOff
    [2014-06-12 15:19:21.502] [I]
    
  • Use of data cell after the upgrade to iOS 10.0.2 has increased dramatically

    Hello:

    I noticed a HUGE increase in mobile data usage by my phone (iPhone 6s) after the iOS to 10.0.2 update.    I had not changed anything since before the update.  A few days after my phone iOS update my more than double to 15 days prior to the cell data update!   I went under a GB to 2.2 GB for two days.  I am only allowed 2.5 GB of my company.   Assist of WiFi was interrupted. I am connected to a wifi most of the time, all day at the office and at home in the morning and in the evening.  I haven't changed my phone usage habits nor have I down loaded new applications.   I also did all the stuff reset once I downloaded the update as turning on and off, hold down home and appears on the sides until that little Apple.

    I looked in the cell parameters section and noticed a few things that consume more data:

    Facebook: I had disabled cell Facebook use.   However, there was a large amount of data used. I also, by habit, only check Facebook when I'm at a known wifi spot as the House or the office.   It was less than a MB before and near a GB of data in 2 days.

    YouTube: Idem, had turned off cell phones and only look at the House.

    Maps - never used but the use of data.

    e-mail-HUGE amount of data used.  Normal use for me. in the past, the amount of data has been a MB.  Now it's 65 MG in 2 days,

    Siri - I do not use Siri as in "Hey Siri" or by using voice commands.  I use it from time to time to the voice on texts.

    AccuWeather.  Even.

    It's just as much as the apps that I use, the rest is electronic mail and stuff systems.   I uninstalled nearly all applications except for the few that I need as my ticket train and planning aps and mail want to stop this.   I won't send any imessages anymore.

    Quite an experience of something like that?

    Yes! I have iPhone 6 - after that the update almost all my data is gone for the month! I do not have Wifi Assist on and I only use data when I'm home and can connect to Wifi!

    I see my iPhone to connect to my Wifi then bounce to the cellular network. I have no problem with my home wifi network. This problem also occurs in the work. In addition, the network at work requires the password to the network - I type in iPhone tells me it's the wrong password, and then it connects. Then it disconnects after 2 minutes.

    I tried to reset the Wifi feature. Help!

  • How to run two 'County of buffered edge' using two different counters at the same time?

    Hello

    I try to use two counters at the same time count the TTL pulses for a fixed period (lets say 10 ms). I have the card PCI-6251 and PCI-6601. I am currently using PCI 6601 as counters and running a self updated the ' stamped edge County - reset.VI. Here, I have attached my VI.

    Now, during the execution of this VI, I get an error saying "error-200251 occurred at Task.vi:4 DAQmx Start" and the possible reasons are, "measures: no USB or DMA channels in loose ends are available.»

    Either stop other tasks which might be using these resources or are considering changing your mechanism for transfer of data to the interruptions if supported.

    Device: Dev2

    Task name: _unnamedTask<80>. »

    What I realized is I'm trying to use two buffers for two meters with ten samples each and this is probably not allowed. I don't know how to solve this out and bad looking for your suggestions.

    Thanks in advance.

    Hi all

    I found a solution too. This is the VI updated the "County of edge stamped" which can simultaneously run two entries-meter using a single source of door and it also uses the DMA and interrupts to save two pads.

    Have a nice weekend.

  • CMD. EXE: IS IT POSSIBLE TO USE TWO COMMANDS INSIDE OF THE COMMAND CMD 'FOR '?

    HAY EVERYONE.
    I WROTE A PROGRAM TO CMD. EXE.
    AND I WANT TO SET A VARIABLE TO THE NUMBER OF FILES PRESENT IN A DIRECTORY.
    THE PROBLEM IS THAT I DON'T KNOW HOW TO USE THE TWO COMMANDS INSIDE OF THE COMMAND.
    HERE IS THE EXAMPLE OF MY PROBLEM INSIDE THE BAT FILE:

    OFF @ECHO
    FOR /F %%D IN (' DIR/W/D / N / L ' "C:\WINDOWS\SYSTEM32\*." ") DLL | TROUVER/C/I/N 'B' ') SET FILES_NUMBER = % Y
    ECHO: % FILES_NUMBER %
    BREAK
    OUTPUT

    I EXPECT THAT THIS PROGRAM WAS TELLING ME HOW MANY DLL FILES THAT BEGIN WITH THE LETTER B, I HAVE IN MY SYSTEM32 DIRECTORY.
    HOWEVER, THIS PROGRAM HAVE A MISTAKE DURING ORDERING.

    | WAS NOT PLANNED AT THIS TIME.

    "WHEN I USE IT JUST COMMAND DIR/W/D O:N: C ' C:\WINDOWS\SYSTEM32\*. "DLL" | " FIND/C/I/N "B" WITHOUT THE FOR ORDER THIS ORDER WRITE A NUMBER ON THE SCREEN. THE NUMBER OF DLL FILES THAT BEGIN WITH THE LETTER B IN MY SYSTEM32 DIRECTORY.
    IF THESE TWO COMMANDS (DIR AND FIND) COMBINED ALL WORK OK.

    BUT I WANT TO REDIRECT THE OUTPUT OF THESE COMMANDS IN A VARIABLE. FOR THIS I USE THE COMMAND FOR.

    WHEN I USE JUST A COMMAND INSIDE THE ORDER, HE DIDN'T THERE WAS NO ERROR.
    BUT WHEN I USE PIPES, A MISTAKE SE PRODUCT.

    SO, MY QUESTION IS: HOW TO USE TWO COMMANDS INSIDE OF COMMAND? OR HOW TO USE A PIPE TO COMMAND INSIDE.

    YBY

    A slightly different method, but will set the Files_Number variable to what you want:

    Off @Echo
    C:
    cd\Windows\System32
    Dir B *. DLL | FindStr.Exe 'File (s)' > Temp.Txt
    FOR /F "Tokens = 1-4" %% IN (Temp.Txt) Set Files_Number = %% a
    Echo number of records Files_Number is %

    Note: You can add a Temp.Txt DEL if you want, but it is not necessary because the > causes the replaced every time that you run this. (If we had used > as our redirector, it adds to the Temp.Txt file, which we don't want.)

    In addition, when you use the / w with the DIR command that calls the large format so you get 1 account per line regardless of the number of files has the letter B in them. Also, your search for the letter B in each line through FIND counted the Bs if they're the first letter.

    My method deliberately DIRs for only these DLLs that begins with the letter B. FindStr allows us to give us only the row that contains the number of files. In the FOR-IN-DO we know that this line will have four elements of the text, so we settled our chips to 1-4. They will be placed in temporary variables a, b, c & d.

    Given that the actual number of files, that's what we want, we have Files_Number = %% a.  Had we wanted to know the total number of bytes of the file, WE Set Total_Bytes = % c.

    You can do both if you want to do like this:

    Off @Echo
    C:
    cd\Windows\System32
    Dir B *. DLL | FindStr.Exe 'File (s)' > Temp.Txt
    FOR /F "Tokens = 1-4" %% IN (Temp.Txt) Set Files_Number = %% a
    FOR /F "Tokens = 1-4" %% IN (Temp.Txt) define Total_Bytes = %% c
    Echo number of records Files_Number is %
    Echo Total number of bytes is Total_Bytes % %

  • Subtracting between two dates and see the result as a date

    HII everyone,

    I had to create a procedure that checks the difference of dates in one month...
    I've got is the view of the difference in the form of date itself...


    for example:

    01/03/2012
    01/03/2012
    01/03/2012
    01/05/2012
    01/05/2012
    .
    .
    so now for a full month...

    the output should be as data are missing for the date 01/04/2012...
    is it possible to display the output as given...
    I am new to oracle, help would be much appreciated...
    Thank you..

    Published by: 948895 on August 2, 2012 21:39

    To fill the gaps between the two dates:

    select &&start_date + (level - 1)
    from dual
    connect by level <= (&&end_date - &&start_date)
    /
    

    To generate the dates for one month:

    select trunc(&&start_date, 'MM')) + (level - 1)
    from dual
    connect by level <= to_number(to_char( last(day(&&start_date)))
    /
    

    This example uses SQL * more variable substitution, but you can easily change to use the value of PL/SQL or everything that you need.

    Cheers, APC

  • Can I do a meeting maker that gives participants the possibility to choose from two dates to attend the event?

    I send a manufacturer of meeting staff and would they be able to choose one of the two dates to be trained. Is this possible without the separate meeting decision makers?

    Sorry, who is not related to Firefox. Seek assistance on the site to help with this program.

    Firefox 3.5.2 is a version of Firefox does not support, you need to update.

    http://www.Mozilla.com/en-us/Firefox/

  • Problems to use two scb-68 has the NI PXI-6225

    Dear nor Forum,.

    I have a chassis NI SMU-1078, with embended OR PXIe8135 controller. One of the slot is busy with a PXI-6225. I for a long time successfully using 1 connection SCB-68 block a with the PXI-6225. Now, I need another channel to analog output on top of OD uses two that I am current. I plugged another SCB-68 connector Panel at the PXI6225, but I could not see analog outputs on this second bedroom. I could not see more channels to DAQmx AO create channel VI

    The PXI-6225 has only 2 analog outputs.  The second connector only has analog inputs.

    If you need more than output analog, you can take a look at the SMU-6738, which includes 32 analog outputs.

  • Can I use two DSL modems in the same House at the same time?

    original title: DSL Modems

    Can I use two different DSL Modems in the same House for two different computers?

    If you want to use on the same connection that want to use on a different connection than Yes and no. But its best to check with your ISP.

  • Double desktop screen "stacked" on first office on a single monitor after using two monitors Netflix to the TV

    Double "stacked" on first desktop on one monitor - desktop screen came just after using two monitors (Netflix on TV extended

    My computer kept crashing after I had hung a dual monitor.  The second monitor was my television, playing a Netflix movie while I also used my computer to work on.  After splitting the two, I kept crashing for a few days.  I tried to delete the second monitor in the display settings, but does not know how to do this, if it's possible, but I think it's the problem and the cause of the double view of the desktop on my computer now.

    Does anyone know how to confirm what the problem is for some, and/or instructions how to solve this problem if you already know what can cause this problem.  No assistance at all would be greatly appreciated.  I tried to understand this two days...

    Note, in the heat of the Las Vegas area, I thought this may be due to overheating, but I actually he cooled in the refrigerator for a short time and restarted, but still have the problem.  Thank you.

    You have a Nvidia 8600 M GS graphics chip located on the motherboard, the drivers for it are provided by your manufacturer, HP, PC-specific to your model and NOT of the site MSUpdate or Nvidia.

    http://www.nvidia.com/object/notebook-Win7-WinVista-258.96-WHQL-driver.html see the following"However, please note that your notebook original equipment manufacturer (OEM) provides certified for your mobile drivers specific to their Web site. NVIDIA recommend you check with your OEM laptop on the software updates recommended for your laptop. The OEM cannot stipulate support technical issues raised by the use of this driver. »

    Since you apperently have a laptop / Notebook, you get all pilots that manufacturers of PC and NOT of MSUpdate site system. Driver version numbers shown on the MSUpdate site cannot be relied on as correct

  • How to use two different versions of the stub of Web Services SDK files in a single project (5.5 and 6.0)

    Hello

    I have a project that uses the vSphere 5.5 management SDK (I built the stub files according to the documentation) and have these in my c# Solution. Everything works beautifully. My class files that interact with vSphere all have a use statement as follows:

    using Vim25Api;

    All fine so far.

    Now, I want to be able to provide support for a user to connect to vSphere 5.5 and 6.0 vSphere environments. I built the stub files for vSphere Management 6.0 SDK and those in my solution presented in a separate project. Each project is based on a different class library and I have each set of files for each version of vSphere stub in different NuGet packages. However, when I select to use a vSphere 5.5 connection, it seems that internally the 6.0 files stub are used, or vice versa.

    I tried to separate things out by giving the Vim25Service.dll and Vim25Service.XmlSerializers.dll files for each version of alias names (alias by default for all assemblies is "global", but I changed it to vSphere5 and vSphere6 for each version. Then at the top of each class file before all with what I'm doing:

    extern alias vSphere5;

    or

    extern alias vSphere6

    (According to what project I'm in). Then, use the using statement for each class file that interacts with vSphere using vSphere5::Vim25Api; or using vSphere6::Vim25Api; to use the files to correct/stub namespace for each version I support.

    However this still doesn't seem to work, and things seem to be getting confused upwards somehow. I take a guess that internal files make calls and somehow have crossed.

    Is it possible to use two stub version of vSphere together different files in the same project? How should I handle my script? I thought of just upgrading to use the version of vSphere 6 (I can always connect to vCenter 5.5 using these, but some of the properties on the object have changed, (for example some dynamic properties on AlarmObjects and other items have been removed and code breaks if I delete the references to the stub vSphere 5.5 files.) So, I want to keep two different versions and use each of them separately in the same solution, so I support vSphere 5.5 and vSphere 6.

    Solved - this using wsdl.exe and just by specifying a different namespace to use in the proxy class that is generated by using the /n switch.

    for example using PowerShell to build automatically, the value $VimApi and do:

    WSDL.exe/n:$ VimApi...

  • use two different characters in the same domain

    Hi, how to use for different fonts in the same field?

    unless "crush you" painting: you do not have.
    If you do, you can use graphics.setFont

Maybe you are looking for