Answered by:
Extract the Year from today + 14?

Question
-
How do I extract the year from today + 14?
This is My attempt:
[Year] = Year(Now() + 14)
Monday, December 14, 2015 3:26 PM
Answers
-
Hi Mark,
Let's try to break down the issue. What do you get when you do each of the following?
MsgBox Year(Date)
MsgBox Date()+14
MsgBox Year(Date+14)
MsgBox Year(DateAdd("d",14,Date()))
- Edited by .theDBguy Monday, December 14, 2015 9:00 PM
- Marked as answer by Mark Matzke Monday, December 14, 2015 9:53 PM
Monday, December 14, 2015 8:37 PM
All replies
-
Hi Mark,
Just a misplaced closing parens:
ThisYearPlus14 = Year(Date()) + 14
Hope that helps...
- Proposed as answer by André Santo Monday, December 14, 2015 4:30 PM
Monday, December 14, 2015 3:47 PM -
Let's try this, forget about adding the 14 days for now.
Access will not let me use: ThisYear = Year(Date())
Access changes it to: ThisYear = Year(Date)
Then I get a Type Mismatched error. I am trying to save it as a 4 digit number, but glad to do text or anything else. Any suggestions?
- Edited by Mark Matzke Monday, December 14, 2015 7:16 PM Grammer
Monday, December 14, 2015 7:15 PM -
Well, let's back up a bit. Where are you trying to use this code? How did you declare the variable ThisYear? If Access insists on converting the function to Year(Date), that's not a problem. Let it...
- Edited by .theDBguy Monday, December 14, 2015 7:21 PM
Monday, December 14, 2015 7:21 PM -
On my main form [Tracker] I have a subform [Emplyee]
This subform form opens to the specific user filtered formthe fOSUserName() command
From thee, the employee can set up preferences on the project, entity and fiscal year.
All work perfectly except for the Year. The user can click on a button to go forward a year, or back. They can also click on a button to be brought back to the current fiscal year (ends roughly 14 days prior to the actual end of the year).
This sounds difficult, but it shouldn't be. I agree that there could be something else that could be wrong, but I have also tried setting a string and kicking the year back on a msgbox, and no matter what I try, I cannot extract a year off of a date.
- Edited by Mark Matzke Monday, December 14, 2015 8:09 PM Grammer
Monday, December 14, 2015 8:08 PM -
Hi Mark,
Let's try to break down the issue. What do you get when you do each of the following?
MsgBox Year(Date)
MsgBox Date()+14
MsgBox Year(Date+14)
MsgBox Year(DateAdd("d",14,Date()))
- Edited by .theDBguy Monday, December 14, 2015 9:00 PM
- Marked as answer by Mark Matzke Monday, December 14, 2015 9:53 PM
Monday, December 14, 2015 8:37 PM