IF Statement Inquiry

kparadise

Board Regular
Joined
Aug 13, 2015
Messages
186
I have a DATE field "Target Date", which I have values for.

I want to create a new DATE column in my access query called "Validation Date".

The "Validate Date" will equal the last day of the year 12/31/2016, 2017, 2018, etc., and is based off of the "Target Date". If the "Target Date" is within the year 2014, the "Validation Date" will be the following year end date, 12/31/2015.

I.E. If the "Target Date" is any day within 2015....the "Validation Date" will be 12/31/2016.
I.E If the "Target Date" is any day within 2016....the "Validation Date" will be 12/31/2017.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Try this:
Code:
Validation_Date: DateSerial(Year([Target Date])+1,12,31)
 
Upvote 0
Since this is a calculation based on data in the table it really should not be stored. Following the rules of Data Normalization (Best Practices) you would calculate the validation date as needed.
 
Upvote 0
Since this is a calculation based on data in the table it really should not be stored. Following the rules of Data Normalization (Best Practices) you would calculate the validation date as needed.
It sounds to me like they weren't trying to, based on the following line from the original question.
I want to create a new DATE column in my access query called "Validation Date".
 
Upvote 0
Jpe4.

You are probably (hopefully) correct.

I read "...create a new DATE column in my access query..." and jumped the gun thinking the query was an UPDATE query. It could mean "...create a new DATE column in my access SELECT query..." or "...create a new DATE column in my access UPDATE query..." since the specific type of query was not mentioned. I took it as the latter.

I like to create a Public User Defined Function (UDF) in a code module to handle the calculation. This way it can easily be used in a query, form, and report, and even a macro. I would pass a date and return the validation date. If the calculation needs updated it is easily changed in a single place.
 
Upvote 0

Forum statistics

Threads
1,215,227
Messages
6,123,738
Members
449,116
Latest member
alexlomt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top