459,504 Members | 1,194 Online
Need help? Post your question and get tips & solutions from a community of 459,504 IT Pros & Developers. It's quick & easy.

# Datediff

 P: n/a Hi When I use datediff, the Year I get back is not correct .At msdn I found the problem.(From 31/12/2003 to 1/1/2004 I get 1Year butt this is not correct. Where can I find a function that give's me the exact Year ( for 31/12/2003 to 1/1/2004 this is 0 Year Thx JoskeXP Nov 20 '05 #1
5 Replies

 P: n/a Hi Joske, Have a look at the timespan http://msdn.microsoft.com/library/de...classtopic.asp I hope this helps better? Cor Nov 20 '05 #2

 P: n/a "JoskeXP" schrieb When I use datediff, the Year I get back is not correct .At msdn I found the problem.(From 31/12/2003 to 1/1/2004 I get 1Year butt this is not correct.) Where can I find a function that give's me the exact Year ( for 31/12/2003 to 1/1/2004 this is 0 Year) 2004 - 2003 = 1 How long is one year? 365 or 366 days? How long is one month? 28, 29, 30 or 31 days? -- Armin How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html Nov 20 '05 #3

 P: n/a * "=?Utf-8?B?Sm9za2VYUA==?=" scripsit: I need this because I have to now of he's at least 21 year's old. When I do 1/1/2004 - 31/12/2003 I get 1 Year but it's only 1 day difference. When he's 20 Year 11 Months and 25 day's I only need 20 Year and noy 21 Year By subtracting the dates, you get a 'TimeSpan'. Check the number of days the timespan includes. -- Herfried K. Wagner [MVP] Nov 20 '05 #4

 P: n/a "JoskeXP" schrieb I need this because I have to now of he's at least 21 year's old. When I do 1/1/2004 - 31/12/2003 I get 1 Year but it's only 1 day difference. When he's 20 Year 11 Months and 25 day's I only need 20 Year and noy 21 Year Public Function GetAge( _ ByVal BirthDate As Date, ByVal ReferenceDate As Date) As Integer GetAge = ReferenceDate.Year - BirthDate.Year If ReferenceDate.Month < BirthDate.Month _ OrElse (ReferenceDate.Month = BirthDate.Month _ AndAlso ReferenceDate.Day < BirthDate.Day) Then GetAge -= 1 End If End Function -- Armin How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html Nov 20 '05 #5

 P: n/a Hi It works perfect. Thank yo Joskexp Nov 20 '05 #6

### This discussion thread is closed

Replies have been disabled for this discussion.