Here is a function where you don't have to worry about the leap year.
You will have to still be aware of time differences between you and
the server, and correct your data before entering it into the
function. And of course time zones, yada yada ....
BUT I think that most people using this will just want to say if today
is there bday than they are their new age.
It first takes the currentYear - birthYear - 1
Then it decides whether it needs to add a year(i.e if they had their
bday). First by just making a number out of the month and day ... it
makes the day 2 digits by adding a '0' in front of a single digit day.
Then puts month and day into one number .. like this
feb 2 = 202
july 10 = 710
oct 8 = 1008
dec 20 = 1220
and yes feb 29 = 229
Then if today is 301 it doesn't care ... 228 and 229 are both less
than 301.
I also added a part to compare ONLY the times ... if the day
comparison = 0 ... i.e. today is there bday
now, if you don't send a time with your date ... no problem ... it
will count today as being their new age
Tell me what you think ... I can clean up the code a bit if anyone
wants me to
<%
Function yearsOld(birthDate)
Dim currentDate, monthDayComparison, addYear: currentDate =
Now()
Dim birthDay, currentDay: birthDay = Day(birthDate):
currentDay = Day(currentDate)
'// Lets take the Date() BS out of the picture!!!
'//Compare Days by making a number out of month & day
.... feb 29 = 229 while oct 8 = 1008
If Len(birthDay) = 1 Then: birthDay = "0" & birthDay:
End If
If Len(currentDay) = 1 Then: currentDay = "0" &
currentDay: End If
monthDayComparison = Int(Int(Month(currentDate) &
currentDay)) - Int(Month(birthdate) & birthDay)
If monthDayComparison > 0 Then '//had birthday this
year
addYear = 1
ElseIf monthDayComparison < 0 Then '//haven't had
birthday this year
addYear = 0
ElseIf monthDayComparison = 0 Then '// birthday today
addYear = 1
Dim timeDifference: timeDifference =
DateDiff("s", Hour(currentDate) & ":" & Minute(currentDate) & ":" &
Second(currentDate), Hour(birthDate) & ":" & Minute(birthDate) & ":" &
Second(birthDate))
If timeDifference > 0 Then: addYear = 0: End
If
End If
yearsOld = Year(currentDate) - Year(birthDate) - 1 + addYear
End Function
%> 3 1869
Similar to aspfaq ... didn't read your post til after ... lol
On Sun, 04 Jan 2004 22:48:38 GMT, z@z.com (Brynn) wrote: Here is a function where you don't have to worry about the leap year.
You will have to still be aware of time differences between you and the server, and correct your data before entering it into the function. And of course time zones, yada yada ....
BUT I think that most people using this will just want to say if today is there bday than they are their new age. It first takes the currentYear - birthYear - 1
Then it decides whether it needs to add a year(i.e if they had their bday). First by just making a number out of the month and day ... it makes the day 2 digits by adding a '0' in front of a single digit day. Then puts month and day into one number .. like this
feb 2 = 202 july 10 = 710 oct 8 = 1008 dec 20 = 1220
and yes feb 29 = 229
Then if today is 301 it doesn't care ... 228 and 229 are both less than 301.
I also added a part to compare ONLY the times ... if the day comparison = 0 ... i.e. today is there bday
now, if you don't send a time with your date ... no problem ... it will count today as being their new age
Tell me what you think ... I can clean up the code a bit if anyone wants me to
<% Function yearsOld(birthDate) Dim currentDate, monthDayComparison, addYear: currentDate = Now()
Dim birthDay, currentDay: birthDay = Day(birthDate): currentDay = Day(currentDate)
'// Lets take the Date() BS out of the picture!!! '//Compare Days by making a number out of month & day ... feb 29 = 229 while oct 8 = 1008 If Len(birthDay) = 1 Then: birthDay = "0" & birthDay: End If If Len(currentDay) = 1 Then: currentDay = "0" & currentDay: End If monthDayComparison = Int(Int(Month(currentDate) & currentDay)) - Int(Month(birthdate) & birthDay)
If monthDayComparison > 0 Then '//had birthday this year addYear = 1 ElseIf monthDayComparison < 0 Then '//haven't had birthday this year addYear = 0 ElseIf monthDayComparison = 0 Then '// birthday today addYear = 1 Dim timeDifference: timeDifference = DateDiff("s", Hour(currentDate) & ":" & Minute(currentDate) & ":" & Second(currentDate), Hour(birthDate) & ":" & Minute(birthDate) & ":" & Second(birthDate)) If timeDifference > 0 Then: addYear = 0: End If End If
yearsOld = Year(currentDate) - Year(birthDate) - 1 + addYear End Function %>
You're working to hard! Take a look at the datediff() function in VS6 help
files. I believe that function will save you a lot of time. I've attached
a crude asp example to this post for you to play with.
God Bless,
Robert
"Brynn" <z@z.com> wrote in message
news:3f***************@news.comcast.giganews.com.. . Here is a function where you don't have to worry about the leap year.
You will have to still be aware of time differences between you and the server, and correct your data before entering it into the function. And of course time zones, yada yada ....
BUT I think that most people using this will just want to say if today is there bday than they are their new age. It first takes the currentYear - birthYear - 1
Then it decides whether it needs to add a year(i.e if they had their bday). First by just making a number out of the month and day ... it makes the day 2 digits by adding a '0' in front of a single digit day. Then puts month and day into one number .. like this
feb 2 = 202 july 10 = 710 oct 8 = 1008 dec 20 = 1220
and yes feb 29 = 229
Then if today is 301 it doesn't care ... 228 and 229 are both less than 301.
I also added a part to compare ONLY the times ... if the day comparison = 0 ... i.e. today is there bday
now, if you don't send a time with your date ... no problem ... it will count today as being their new age
Tell me what you think ... I can clean up the code a bit if anyone wants me to
<% Function yearsOld(birthDate) Dim currentDate, monthDayComparison, addYear: currentDate = Now()
Dim birthDay, currentDay: birthDay = Day(birthDate): currentDay = Day(currentDate)
'// Lets take the Date() BS out of the picture!!! '//Compare Days by making a number out of month & day ... feb 29 = 229 while oct 8 = 1008 If Len(birthDay) = 1 Then: birthDay = "0" & birthDay: End If If Len(currentDay) = 1 Then: currentDay = "0" & currentDay: End If monthDayComparison = Int(Int(Month(currentDate) & currentDay)) - Int(Month(birthdate) & birthDay)
If monthDayComparison > 0 Then '//had birthday this year addYear = 1 ElseIf monthDayComparison < 0 Then '//haven't had birthday this year addYear = 0 ElseIf monthDayComparison = 0 Then '// birthday today addYear = 1 Dim timeDifference: timeDifference = DateDiff("s", Hour(currentDate) & ":" & Minute(currentDate) & ":" & Second(currentDate), Hour(birthDate) & ":" & Minute(birthDate) & ":" & Second(birthDate)) If timeDifference > 0 Then: addYear = 0: End If End If
yearsOld = Year(currentDate) - Year(birthDate) - 1 + addYear End Function %>
I was just playing around more than anything ... they were arguing it
in another thread ... aspfaq.com has a script to identify leap year
babies, but I don't think that it will come up with a different result
than ...
age = Int(DateDiff("d",dob, Date()) / 365.25)
then if someone REALLY wanted to go by the time of birth for whatever
crazy reason ... they could just
addToAge = DateDiff( "s", Hour(dob) & ":" & Minute(dob) & ":" &
Second(dob), Hour(Date()) & ":" & Minute(Date)) & ":" &
Second(Date()))
If addToAge =< 0 Then: age = age + 1: End if
I have yet to find where dividing the difference by 365.25 will not
give the correct response
Thanks for the input though Robert :)
Take Care,
Brynn www.coolpier.com
On Sun, 4 Jan 2004 16:59:02 -0800, "Robert Suffecool"
<rm*****@hotmail.com> wrote: You're working to hard! Take a look at the datediff() function in VS6 help files. I believe that function will save you a lot of time. I've attached a crude asp example to this post for you to play with.
God Bless,
Robert
"Brynn" <z@z.com> wrote in message news:3f***************@news.comcast.giganews.com. .. Here is a function where you don't have to worry about the leap year.
You will have to still be aware of time differences between you and the server, and correct your data before entering it into the function. And of course time zones, yada yada ....
BUT I think that most people using this will just want to say if today is there bday than they are their new age. It first takes the currentYear - birthYear - 1
Then it decides whether it needs to add a year(i.e if they had their bday). First by just making a number out of the month and day ... it makes the day 2 digits by adding a '0' in front of a single digit day. Then puts month and day into one number .. like this
feb 2 = 202 july 10 = 710 oct 8 = 1008 dec 20 = 1220
and yes feb 29 = 229
Then if today is 301 it doesn't care ... 228 and 229 are both less than 301.
I also added a part to compare ONLY the times ... if the day comparison = 0 ... i.e. today is there bday
now, if you don't send a time with your date ... no problem ... it will count today as being their new age
Tell me what you think ... I can clean up the code a bit if anyone wants me to
<% Function yearsOld(birthDate) Dim currentDate, monthDayComparison, addYear: currentDate = Now()
Dim birthDay, currentDay: birthDay = Day(birthDate): currentDay = Day(currentDate)
'// Lets take the Date() BS out of the picture!!! '//Compare Days by making a number out of month & day ... feb 29 = 229 while oct 8 = 1008 If Len(birthDay) = 1 Then: birthDay = "0" & birthDay: End If If Len(currentDay) = 1 Then: currentDay = "0" & currentDay: End If monthDayComparison = Int(Int(Month(currentDate) & currentDay)) - Int(Month(birthdate) & birthDay)
If monthDayComparison > 0 Then '//had birthday this year addYear = 1 ElseIf monthDayComparison < 0 Then '//haven't had birthday this year addYear = 0 ElseIf monthDayComparison = 0 Then '// birthday today addYear = 1 Dim timeDifference: timeDifference = DateDiff("s", Hour(currentDate) & ":" & Minute(currentDate) & ":" & Second(currentDate), Hour(birthDate) & ":" & Minute(birthDate) & ":" & Second(birthDate)) If timeDifference > 0 Then: addYear = 0: End If End If
yearsOld = Year(currentDate) - Year(birthDate) - 1 + addYear End Function %>
begin 666 datediff.asp M/$A434P^#0H\2$5!1#X-"CQ-151!($Y!344](D=%3D52051/4B(@0V]N=&5N M=#TB36EC<F]S;V9T(%9I<W5A;"!3='5D:6\@-BXP(CX-"CQ4251,13Y(;W<@ M;VQD(&%R92!Y;W4_/"]4251,13X-"CPO2$5!1#X-"CQ"3T19/@T*#0H\)4EF M(%)E<75E<W0N1F]R;2@B='AT1$]"(BD@/#X@(B(@5&AE;@T*"0T*"5)E<W!O M;G-E+E=R:71E*")9;W4@87)E("(@)B!R;W5N9"AD871E9&EF9B@B9 "(L4F5Q M=65S="Y&;W)M*")T>'1$3T(B*2QN;W<I+S,V-2PR*2 F("(@>65A<G,@;VQD M(2(I"0T*"0T*("!E;'-E("4^#0H-"CQF;W)M(&UE=&AO9#TB<&]S="(@86-T M:6]N/2(O9&%T961I9F8N87-P(CX-"D1/0C\@/$E.4%54(&ED/71X=$1/0B!S M='EL93TB3$5&5#H@,3!P>#L@5$]0.B Q-G!X(B -"FYA;64]='AT1$]"/@T* M/$E.4%54(&ED/7-U8FUI=#$@<W1Y;&4](DQ%1E0Z(#(U-G!X.R!43U Z(#$U M<'@B('1Y<&4]<W5B;6ET('9A;'5E/5-U8FUI="!N86UE/7-U8FUI=#$^/"]F M;W)M/@T*/"5E;F0@:68E/@T*#0H-"@T*#0H-"@T*#0H\+T)/1%D^#0H\+TA4 %34P^#0H` ` end This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Surya Kiran |
last post by:
Hi all,
I've written a function template. say
template <class T>
fn (T var) { ... }
Is there any way, from within the function, can we check what type of
argument we've passed on to the...
|
by: P Srinivasulu |
last post by:
Hi All,
Has the MBREquals function been implemented in the latest 4.1.1-alpha
build. I am finding problems with that command. It says that problem is
there in sql syntax. If it has been...
|
by: Petr Jakes |
last post by:
I have got names of functions stored in the file. For the simplicity
expect one row only with two function names: printFoo, printFOO
In my code I would like to define functions and then to read...
|
by: switzerland qunatium computer |
last post by:
HERE I BUILT A QUICK MATRIX TOOOK 5 MINS
Body: HERE I BUILD ONE FOR YOU
1.http://en.wikipedia.org/wiki/Real-time_computing
2.http://en.wikipedia.org/wiki/Quantum_computing
NOW ALL YOU NEED...
|
by: Patient Guy |
last post by:
The code below shows the familiar way of restricting a function to be a
method of a constructed object:
function aConstructor(arg)
{
if (typeof(arg) == "undefined")
return (null);...
|
by: Sonnich |
last post by:
Hi
Is the such a function like IN in delphi:
if( $somechar in )
dsafsakjldg;
where true is for the characters mentioned above.
BR
|
by: Bryan Parkoff |
last post by:
Do you know that current C++ Compiler limits to 64KB segments in source
code? It is good news that Microsoft Visual C++ 2005 has expanded to 4GB
segments in source code. 4GB segment is ideal for...
|
by: mkhan |
last post by:
Hi, i have been having trouble how to open the 'To' Contacts list(Cc or To) (address book) of a mail message in outlook using vb.net from where the user would be able to select an email address and...
|
by: sophia |
last post by:
Dear all,
can any one suggest ways of implementing a backtrace function in ANSI/
standard C as given in the following link ?
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |