ip1000
-
Total Posts
:
1
- Scores: 0
-
Reward points
:
0
- Joined: 7/16/2007
-
Status: offline
|
Code for the exact age
Thursday, July 19, 2007 7:33 AM
( permalink)
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
|
|
|
|
Country73
-
Total Posts
:
754
- Scores: 10
-
Reward points
:
0
-
Status: offline
|
RE: Code for the exact age
Friday, July 20, 2007 12:40 AM
( permalink)
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: iYearDifference = DateDiff("yyyy", dtY2K, dtNow) You are using the year to find the YearDifference
|
|
|
|