Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - DoB - Star Sign and Age
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

DoB - Star Sign and Age

 Post Reply Post Reply
Author
Mattblack View Drop Down
Groupie
Groupie
Avatar

Joined: 21 January 2003
Location: United Kingdom
Status: Offline
Points: 139
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mattblack Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Mattblack View Drop Down
Groupie
Groupie
Avatar

Joined: 21 January 2003
Location: United Kingdom
Status: Offline
Points: 139
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mattblack Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Mattblack View Drop Down
Groupie
Groupie
Avatar

Joined: 21 January 2003
Location: United Kingdom
Status: Offline
Points: 139
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mattblack Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Mattblack View Drop Down
Groupie
Groupie
Avatar

Joined: 21 January 2003
Location: United Kingdom
Status: Offline
Points: 139
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mattblack Quote  Post ReplyReply Direct Link To This Post 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!
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post 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)
Back to Top
Mattblack View Drop Down
Groupie
Groupie
Avatar

Joined: 21 January 2003
Location: United Kingdom
Status: Offline
Points: 139
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mattblack Quote  Post ReplyReply Direct Link To This Post Posted: 04 December 2004 at 1:38pm
aaaah, i didnt know you could do that "Day" and "Month" thing. Will have a go. Thanks
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.