Access date calculations - ms-access

I have an access Table with a criteria that asks for a value:
[LAST CYCLE DATE YYMMDD]
I want to replace it with a calculated value for yesterday's date:
[LAST-PMT-DATE]=date()-1
this returns zero rows
but if I use [LAST-PMT-DATE]='180611' I get what I expect to see
What is the correct syntax my my calculated date?
Any help would be appreciated!
....further I tried this but get another error:
[LAST-PMT-DATE]=FORMAT(DATE()-1,"YYMMDD")

This is the solution:
[LAST-PMT-DATE]=FORMAT(DATE()-1,"YYMMDD")
The error I was getting, in my example, was the result of an extra ")", that was part of the full piece of code.

Related

how to get an integer from the current year in Microsoft access

I want to get the current year and minus it from another year and have the result be an integer.
To do this, do I have to use a calculated column and what code would I have to use.
I have tried things such as Date() however it always tells me that I cannot use it in a calculated column.
Thanks
That could be this expression in a query:
YearDiff: [OtherYear]-Year(Date())

Adding Parameter to DateDiff Function

Not sure I am going at this the best way, I would like to make the last parameter of the DateDiff formula something the user enters. I get the parameter popup, but when I enter the desired date in the popup I get an error (screen shot of error is below):
Interest Days: DateDiff("d",Nz([Loan]![SetupDate],DateAdd("m",-1,[Loan]![CreationDate])),Format([Enter the date you wish to pull from],"mm/dd/yyyy")+1)
I have tried putting a # in the parameter popup and I also tried not putting the parameter in a Format, like this but it results in the same error:
Interest Days: DateDiff("d",Nz([Loan]![SetupDate],DateAdd("m",-1,[Loan]![CreationDate])),[Enter the date you wish to pull from]+1)
Error Message
First, specify the Parameter as DateTime:
[Enter the date you wish to pull from]
Next, use it as a date:
Interest Days: DateDiff("d",Nz([Loan]![SetupDate],DateAdd("m",-1,[Loan]![CreationDate])),[Enter the date you wish to pull from])+1

SSRS IIF expression giving only partial output

I have a simple IIF statement to say if the actual date is blank, show me TBC. Otherwise, show me what the actual date is. I can successfully get the TBC. But I cannot get the actual date to show where I know there is a date. Any help is appreciated.
=IIF(Fields!VPSR_Actual_Date.Value = "", "TBC", Fields!VPSR_Actual_Date.Value)
I'd do a check if the column is null or zero string and then format the date.
=IIF(IsNothing(CStr(Fields!VPSR_Actual_Date.Value)) OR CStr(Fields!VPSR_Actual_Date.Value) ="", "TBC", Format(Fields!VPSR_Actual_Date.Value, "dd-MMM-yyyy"))

Access parameter query with optional second parmeter

I have an ACCESS database that has a table with date as one of the fields. I can create a form that allows the user to enter a start date and end date and then use those in a query to filter the date for only records between those dates. But I would like to make the end date optional so if the user would only enter the start date the query would return on records greater than that date. I am trying to do this with one query and without getting into VBA but not sure if this can be done.
I tried something like this but it did not work...I got error message saying the syntax was not correct or I got no results at all.
In the date field criteria I tried
IIF(isNull([Forms]![frmdateselect]![enddate]),
(>=DateValue([Forms]![frmdateselect]![startdate])),
((>=DateValue([Forms]![frmdateselect]![startdate])) AND
(<=DateValue([Forms]![frmdateselect]![enddate]))))
Any help would be great
Have you tried replacing the IsNUll with the Nz function?
IIF(Nz([Forms]![frmdateselect]![enddate]),0),
([Forms]![frmdateselect]! [enddate]),
(>=DateValue([Forms]![frmdateselect]![startdate])),
((>=DateValue([Forms]![frmdateselect]![startdate])) AND
(<=DateValue([Forms]![frmdateselect]![enddate]))))

MS Access - Use result from query to calculate field value

I'm trying to pull some data from a query in my database into a calculated field in a table. I have dates entered for some jobs I'm recording (DateCallOpened, DateQuoteSent, DateQuoteReceived), as well as WorkType for each job to track the type of work done. I've used calculated fields to find the time it took for each record between those dates. I've also used qryTimings to find the average length of time for the WorkType.
I'd like to build fields that showed the ProjectedQuoteSent, and use the data from my query to calculate the date I can expect the quote to be sent, but I just can't figure out how to pull that data out of the query. I was hoping it would be something as simple as:
=[DateCallOpened]+[qryTimings]:[Avg Of TimeToSendQuote]
You can use a DLookup() function to grab your value from your query. So your formula would be something like:
=[DateCallOpened]+DLookup("Avg Of TimeToSendQuote", "qryTimings", _
"[WorkType]=" & [Forms]![frmMyForm]![txtWorkTypeInput])
See this for more info.