Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Code for the exact age

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,49706
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> Code for the exact age
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Code for the exact age - 7/19/2007 6:33:36 AM   
  ip1000

 

Posts: 1
Score: 0
Joined: 7/16/2007
Status: offline
The following code will calculate the exact age on users from a DDBB, but somehow itīs giving me back the total number of years just taking in consideration the year and not using the month or day to correct the age.
 
<%
Dim dtNow, dtY2K
dtNow = Date()
dtY2K = DateSerial((Recordset.Fields.Item("bornyear").Value), (Recordset.Fields.Item("bornmonth").Value), (RecordsetCV.Fields.Item("bornday").Value))
 
 
Dim iYearDifference
iYearDifference = DateDiff("yyyy", dtY2K, dtNow)
%>
<%Response.write""&iYearDifference&""%>
 
Any input on why itīs not using the month and day to find the YearDifference?
 
Thanks in advance,
 
Ignacio Francisco Penin
 
 
Post #: 1
 
 RE: Code for the exact age - 7/19/2007 11:40:02 PM   
  Country73


Posts: 710
Score: 8
Joined: 8/25/2004
From: USA
Status: offline
DateDiff(interval, date1, date2 [,firstdayofweek [, firstweekofyear]])
  • interval      Required. String expression that is the interval you want to use to calculate the differences between date1 and date2.
  • date1, date2     Required. Date expressions. Two dates you want to use in the calculation.
  • firstdayofweek  Optional. Constant that specifies the day of the week. If not specified, Sunday is assumed. See Settings section for values.
  • firstweekofyear  Optional. Constant that specifies the first week of the year. If not specified, the first week is assumed to be the week in which January 1 occurs.
    Your line:
    quote:

    iYearDifference = DateDiff("yyyy", dtY2K, dtNow)

    You are using the year to find the YearDifference

    (in reply to ip1000)
  •  
     
    Post #: 2
     
     
     
      

    If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
    All Forums >> [Scripting] >> ASP >> Code for the exact age Page: [1]
    Jump to:





    New Messages No New Messages
    Hot Topic w/ New Messages Hot Topic w/o New Messages
    Locked w/ New Messages Locked w/o New Messages
     Post New Thread
     Reply to Message
     Post New Poll
     Submit Vote
     Delete My Own Post
     Delete My Own Thread
     Rate Posts