My Assistant
![]() ![]() |
|
|
May 5 2012, 07:25 AM
Post
#1
|
|
|
UtterAccess Addict Posts: 224 |
I have a table that lists the year a piano is made. The specific date is unknown only the year. I want to find the age of the piano. in the past I have used "DateDiff("yyyy",[YearBuilt],Date())" as a way t find date diff but this time it recognizes all the dates as the same. is there a way to calculate the age using the year only?
|
|
|
|
May 5 2012, 07:40 AM
Post
#2
|
|
|
Utter A-fishin'-ado Posts: 17,723 From: Cincinnati, Ohio, USA . . . ><((((°> |
Using the DateSerial function, change your YearBuilt into a real date. Then use the result of that function in your DateDiff function.
|
|
|
|
May 5 2012, 07:43 AM
Post
#3
|
|
|
UtterAccess Editor Posts: 15,974 From: Northern Virginia, USA |
If you are happy with your expression, then you just have to assume a month and day ...
IIf([YearBuilt] Is Null, Null, DateDiff("yyyy",CDate([YearBuilt] & "-01-01"),Date())) But one thing that is important to know is that DateDiff() will only consider the interval you are wanting the result in. For example: DateDiff("yyyy",#2012-12-31#,#2013-01-01#) = 1 So, even though the two dates are only different by a day, the result is 1 year because that is the unit being evaluated is the year. |
|
|
|
May 5 2012, 08:07 AM
Post
#4
|
|
|
UtterAccess Addict Posts: 224 |
Thanks I will try it All the pianos in question are OLD
|
|
|
|
May 5 2012, 08:56 AM
Post
#5
|
|
|
UtterAccess Editor Posts: 15,974 From: Northern Virginia, USA |
Your welcome ... Ya know, since you just have the Year, you really don't need the DateDiff() function --- or DateSerial()! ... you can just get the year portion of the current date....
Year(Date()) - [YearBuilt] |
|
|
|
May 6 2012, 11:56 PM
Post
#6
|
|
|
UtterAccess Addict Posts: 224 |
This fits the bill perfectly! Thanks (IMG:style_emoticons/default/woohoo.gif)
|
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 23rd May 2013 - 05:50 PM |