| Author |
Topic Search Topic Options
|
Mattblack
Groupie
Joined: 21 January 2003
Location: United Kingdom
Status: Offline
Points: 139
|
Post Options
Thanks(0)
Quote Reply
Topic: DoB - Star Sign and Age 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
|
 |
Gullanian
Senior Member
Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
|
Post Options
Thanks(0)
Quote Reply
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.
Edited by Gullanian - 25 November 2004 at 9:16pm
|
 |
Mattblack
Groupie
Joined: 21 January 2003
Location: United Kingdom
Status: Offline
Points: 139
|
Post Options
Thanks(0)
Quote Reply
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.

|
 |
Gullanian
Senior Member
Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
|
Post Options
Thanks(0)
Quote Reply
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.
|
 |
Mattblack
Groupie
Joined: 21 January 2003
Location: United Kingdom
Status: Offline
Points: 139
|
Post Options
Thanks(0)
Quote Reply
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
|
|
 |
Mattblack
Groupie
Joined: 21 January 2003
Location: United Kingdom
Status: Offline
Points: 139
|
Post Options
Thanks(0)
Quote Reply
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!
|
 |
dj air
Senior Member
Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
|
Post Options
Thanks(0)
Quote Reply
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)
|
 |
Mattblack
Groupie
Joined: 21 January 2003
Location: United Kingdom
Status: Offline
Points: 139
|
Post Options
Thanks(0)
Quote Reply
Posted: 04 December 2004 at 1:38pm |
|
aaaah, i didnt know you could do that "Day" and "Month" thing. Will have a go. Thanks
|
 |