Print Page | Close Window

DoB - Star Sign and Age

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: General Discussion
Forum Description: General discussion and chat on any topic.
URL: https://forums.webwiz.net/forum_posts.asp?TID=12703
Printed Date: 01 April 2026 at 5:14pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: DoB - Star Sign and Age
Posted By: Mattblack
Subject: DoB - Star Sign and Age
Date Posted: 25 November 2004 at 7:27pm
Evening all.

I have a database query which can bring up a person's Date Of Birth (which they input when registering) but I want to be able to convert this to age (to month and day, not just year) and also be able to work out the star sign.

Any of u genious people able to assist?  Or tell me where to start



Replies:
Posted By: Gullanian
Date Posted: 25 November 2004 at 9:16pm
Use datediff()

http://www.w3schools.com/vbscript/func_datediff.asp

Years Difference = First get the years difference
Months Difference = Then month difference minus year difference * 12
Days Difference = Then day difference minus year difference * 365.


Posted By: Mattblack
Date Posted: 26 November 2004 at 8:21am

Thanks pal, confused me a bit there though.  I got this...
response.write (datediff("m","26/11/1984","26/10/2004")/12)

but i get this result...19.9166666666667

But if i round that result to 0 point, then i get 20, when that person is really only 19 still.
Confused



Posted By: Gullanian
Date Posted: 26 November 2004 at 8:54am

Dim years
Dim months
Dim days
Dim datFromDB

datFromDB = rs("date_field_name")

years = dateDiff("y",datFromDB,now())
months = dateDiff("m",datFromDB,now())
months = months - (years * 12)
days = dateDiff("d",datFromDB,now())
days = days - (years - 365)


I think that should work fine.


Posted By: Mattblack
Date Posted: 26 November 2004 at 4:35pm
Excellent, i used that and changed it a bit. This works perfect...
 

ageY=(dateDiff("m",rs("dob_field"),now()))/12
x="1"
do until x="130"
if ageY >= x then
age=x
end if
x=x+1
loop
 
response.write age
 
Big smile


Posted By: Mattblack
Date Posted: 04 December 2004 at 12:57pm
ok, anyone now know how i can get a DoB to be converted into star sign??? Assuming that I have the dates for the star sign.
 
Something along the lines of, if DoB is between x and y then res.write Sagitarious, etc.
 
Its getting the Dob between x and y im struggling with, because the years will vary.
 
ARGH!


Posted By: dj air
Date Posted: 04 December 2004 at 1:05pm
hes an idea


if ((Month(datevalue) = 1 AND DAY(DateValue) > 21) OR (Month(datevalue) = 2 AND DAY(DateValue) < 20)) then

 StarSign = "value

elseif ((Month(datevalue) = 2 AND DAY(DateValue) > 21) OR (Month(datevalue) = 3 AND DAY(DateValue) < 20)) then

starSign = "value

elseif ((Month(datevalue) = 3 AND DAY(DateValue) > 21) OR (Month(datevalue) = 4 AND DAY(DateValue) < 20)) then

starSign = "value"

END IF ..


please note that is ony 3 months. you need to copy that till you get all 12. also will need to make sure the Days are correct (im not sure)


Posted By: Mattblack
Date Posted: 04 December 2004 at 1:38pm
aaaah, i didnt know you could do that "Day" and "Month" thing. Will have a go. Thanks



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net