Calculated field expression help?

towners

Board Regular
Joined
Mar 12, 2009
Messages
225
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I'm brand new to access and wondered if I could get some help creating a calculated field based on results of some logical tests?

I want to create a calculated “Target Install” date field using dates from 3 date fields in a table: “ProvStartDate”, “PIDate” & “Contract Date”.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p> </o:p>
The logic to populate the “TargetInstallDate” is:<o:p></o:p>
<o:p> </o:p>
If “ProvStartDate” is not null use that, if “ProvStartDate” is null and “PIDate” is not null use the “PIDate”, if both “ProvStartDate” and “PIDate” are null then use “ContractDate” + 35 days.<o:p></o:p>
<o:p> </o:p>
Can anyone help me build the expression?<o:p></o:p>

Many thanks

Paul
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Paul

You can try something like this:

InstallDate:Nz([ProvStartDate], Nz([PIDate], DateAdd("d", 35,[Contract Date])))
 
Upvote 0
Norrie,

That's done the trick. Thank you very much.

Regards

Paul
 
Upvote 0
Hi Norrie,

Thanks again for the help. I've noticed though that the results are not formatted as date (even though I have selected this in the field properties). This gives me a data mismatch in a follow up query. When I sort the field ascending it sorts as a number. Any advice to what I'm doing wrong?

Thanks again

Paul
 
Upvote 0
Paul

How exactly are you using the expression?

Also where are you using it and what's giving the error?

If you have dates in those 3 fields then it should return a date value?

It should be formatted as a date too.

How is it formatted? Just a 5 digit number like 40810.*

*That's supposed to be today, might be out a bit though.:)
 
Upvote 0
Hi Norrie,

I've created a calculated field within a query (PT_TargetInstallDate) that joins to my "Contracts" table. Then I join the query to another table that contains dates and corresponding weeknumbers, month and year. The date is calculated correctly and displayed as a date...

A way around this may be if access has the similar functionality as excel to seperate out the weeknumber, month and year i.e.:

weeknumber=weeknumber(serialnumber,returntype)
month=text(serialnumber,format)
year=year(serialnumber)

Regards

Paul
 
Upvote 0
Paul

I don't understand, have you used the expression I posted?

By the way, Access has most (if not all) of the date functions that Excel has.
 
Upvote 0
Hi Norrie,

Yes, I cut and pasted it - the calculations work exactly.

Regards

Paul
 
Upvote 0
Sorted now, have found the Access functionality so no need to create a join to my lookup table.

Thanks for the help Norrie.

Paul
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,285
Members
452,902
Latest member
Knuddeluff

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