473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

working out the age. Help needed urgently!

This is just simple stuff I know, but I need help with it please. As you can see below I have asked for the DOB to be entered, but how do I get it to work out the persons age from their DOB to todays date?

var canvas;
canvas = openGraphics();

var phrase;
phrase = "Your name:";

var phrase2;
phrase2 = "Your Date of birth:";

var phrase3;
phrase3 = "Your mobile number:";

var phrase4;
phrase4 = "your email address:";

var name;
name = prompt("Please enter your name");

var DOB;
DOB = prompt("Please enter your date of birth DD/MM/YY");

var mobile;
mobile = prompt("Please enter your mobile number");

var email;
email = prompt("Please enter your email address");

var message;
message = phrase + name;

var message2;
message2 = phrase2 + DOB;

var message3;
message3 = phrase3 + mobile;

var message4;
message4 = phrase4 + email;

canvas.drawString( message, 10, 10);

canvas.drawString( message2, 10, 30);

canvas.drawString( message3, 10, 50);

canvas.drawString( message4, 10, 70);

canvas.paint();
Mar 5 '07 #1
5 1742
acoder
16,027 Expert Mod 8TB
Use
Expand|Select|Wrap|Line Numbers
  1. var today = new Date();
then see this page to see how you can use the Date object,
Mar 5 '07 #2
mrhoo
428 256MB
DOB = prompt("Please enter your date of birth DD/MM/YY",'');

Expand|Select|Wrap|Line Numbers
  1. try{
  2.     var D=DOB.split(/\W+/);
  3.     for(var i=0;i<3;i++){
  4.         D[i]=Number(D[i]);
  5.     }
  6.     --D[1];
  7.     var age= new Date()- new Date(D[2],D[1],D[0]);
  8.     age= Math.floor(age/3.15576e10);
  9. }
  10. catch(er){
  11.     DOB = prompt("Enter digits for the day, month and year, separated by / characters",'');
  12. }
Mar 5 '07 #3
acoder
16,027 Expert Mod 8TB
MrHoo, let me guess, 3.15576e10 is the number of seconds in a millennium, right?
Mar 6 '07 #4
mrhoo
428 256MB
MrHoo, let me guess, 3.15576e10 is the number of seconds in a millennium, right?
Yes, but it is also the number of milliseconds in 365.25 days:
1000*60*60*24*365.25=31557600000
Mar 6 '07 #5
acoder
16,027 Expert Mod 8TB
Yes, but it is also the number of milliseconds in 365.25 days:
1000*60*60*24*365.25=31557600000
Aah, that makes more sense. Thanks.
Mar 6 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Kamliesh Nadar | last post by:
Hi I am developing a software using VB.NET I am facing following problems - 1. Though I have placed the NotifyIcon control on the window service application, after starting the service I am...
37
by: Art | last post by:
Hello everyone, I am interested in starting an all volunteer website which will be directed at recovering missing children. I am aware that there are few other sites out there with the same...
5
by: el prinCipante | last post by:
I'm getting tired of the following error message. Compiler Error message : Error: Need explicit cast to convert from: float to: float * I am trying to use a routine from the Numerical Recipes...
2
by: senthilkumaramani | last post by:
Hi EveryBody, I am using wixdows Xp. In my machine whenever i run the .net webapplication for that time i did't work internet. If i want to access internet means i do the following options....
4
by: Joonshik Kim | last post by:
I was trying to define 3d array with pointer to pointer. I wrote like following. int ***d; nx = 3; ny = 5; nz = 4; d = (int ***)malloc((int) nx*sizeof(int **)); *d = (int **)malloc((int)...
1
by: janakivenk | last post by:
Hello, I am running Oracle 10g R2 in our office. I created the following procedure. It is suppose to access an xml file ( family.xml). The procedure is compiled and when I try to run it, i get the...
1
by: itskaps | last post by:
Hi all, My following program code works fine on win 2K server but the same is not working on win2K3 server. It's showing error as page cannot be displayed. After debugging, I found that...
6
by: crack.the.hack | last post by:
Hi All, If I am changing the database machine, what should I do not to prep bind the sqc files everytime. Because I need to build my application everytime the database is changed? Is there...
1
by: Robert Wells | last post by:
Gentlemen, We are looking for two IBM documents that are needed urgently for a project. They are titled "4680 Store Systems Serial I/O Channel Attachment Information" and "Serial I/O Product...
19
by: uhdam | last post by:
Hai... I need to have image as tooltip. Is it possible. If yes how. I dont want to use applet. When i scroll over the label in my frame the pop up containing the image should be displayed. How can...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.