create a dynamic title that displays date range as per the start and enddate parameters used - date

I have a report that displays monthly and ytd amounts. I use start and enddate parameters that change according to the user. For example for startdate 4/1/2007 and enddate 2/28/2008
1. I need to display title as Monthly budget 2/1/2008 to 2/28/2008
2. I need to display title for YTD as YTD 4/1/2007 to 2/28/2008
I tried = Parameter!EndDate.value but it throws error

It looks like you may have missed a letter in your expression. It should be:
=Parameters!EndDate.Value
In the expression editor you can double click on the parameter name and it will insert it into the expression for you.
To get the full description that you mentioned, you'll need to use a combination of functions. One useful one to look at is DateAdd to add days and months to the specified date. Another one is FormatDateTime which allows you to use the standard "ShortDate" format.
If you run into further trouble, I would recommend posting a new question with the variations of code that you tried along with the specific error messages that you received.

You could try setting the Expression for a text box to:
="Monthly Budget " & FORMAT(Paramters!StartDate.Value, "MM/dd/yyyy") & " to " & "FORMAT(Paramters!EndDate.Value, "MM/dd/yyyy")
This will give you:
Monthly Budget 02/01/2008 to 02/28/2008
It is the same for your second requirement, just change the wording.

Related

Google Sheets - DATE format not working on imported Date in TEXT format

I text based .csv file with a semicolon separated data set which contains date values that look like this
22.07.2020
22.07.2020
17.07.2020
09.07.2020
30.06.2020
When I go to Format>number> I see the Google sheets has automatic set.
In this state I cannot use and formulas with this data.
I go to Format>number> and set this to date but formulas still do not see the actual date value and continue to display an error
Can someone share how I can quickly activate the values of this array so formulas will work against them?
I would be super thankful
Where the date are in column A, starting in cell A1, this formula will convert to DATE as a number, after which you apply formatting to Short Date style.
=ARRAYFORMULA(IF(A1:A="",,DATE(RIGHT(A1:A,4),MID(A1:A,4,2),LEFT(A1:A,2))))
Hopefully(!) the dates stay as text, otherwise Google Sheets would sometimes detect MM/dd/yyyy instead of dd/MM/yyyy, and you won't be able to distinguish between July 9th and September 7th in your example.
Solution #1
If your locale is for instance FR, you can then apply
=arrayformula(if(A1:A="";;value(A1:A)))
solution#2
you can try/adapt
function importCsvFromIdv1() {
var id = 'the id of the csv file';
var csv = DriveApp.getFileById(id).getBlob().getDataAsString();
var csvData = Utilities.parseCsv(csv);
csvData.forEach(function(row){
date = row[0]
row[0] = date.substring(6,10)+'-'+date.substring(3,5)+'-'+date.substring(0,2)
})
var f = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
f.getRange(1, 1, csvData.length, csvData[0].length).setValues(csvData);
}
First thanks to those that suggested a fix. I am not really a programmer and get cold sweats when I see suggesting of running scripts to solve simple problems. Sorry guys.
So the (non programmer) solution with the dates was to do a find/replace (CTRL + H) and replace all the (.)dots with (/)slashes, then to make sure the column is formatted as a date, then Google finally understands it as a date.
With the accounting values as well, I had to do the same find/replace to remove all the ' between thousands, then google woke up and understood them as numbers.
I am significantly underwhelmed by this from Google. They are getting too fat and lazy. They need some competition.

Google spreadsheet month name (MMMM) without declension

I want to display formatted month name in the basic form (nominative) as a label. In Czech language (and several next Slavic languages) we use declension. So if I use =TEXT(NOW();"MMMM") the cell shows month name in genetive instead of nominative (i.e. srpna instead of srpen).
Q: How to format the date in the nominative? The acceptable solution will offer some native way how to solve it but not:
manipulating with strings (month names are too complex)
having some another list with month names
calling own formula (Google script)
Maybe there is no native way how to solve this and it will be implemented in the future, so Google Script seems to be the easiest hotfix for now. And because I'm expecting many answers with the script, I'm putting the one here but this question is not about the javascript/google-script.
function monthName(date) {
var months = ["Leden","Únor","Březen","Duben","Květen", "Červen","Červenec","Srpen","Září","Říjen","Listopad","Prosinec"];
return months[date.getMonth()];
}

How to check if date equals date of datetime property only using query parameters

I have a DateTime property.
I want to check if a date is equal to the date in my property and it has to be done purely in the url query parameters available in OData v4.
This doesn't work :(
GET ~/odata/foo$filter=date(myProperty) eq date(1980-01-01)
Yes I can use greater then or equal but that's is already working as intended. It's equal and not equal that's the problem.
From ABNF rules, Date value is a value with format:
dateValue = year "-" month "-" day
So, I think you shouldn't add date prefix. That's:
GET ~/odata/foo$filter=date(myProperty) eq 1980-01-01
Here's some test cases provided by ODataTeam:
https://github.com/OData/WebApi/blob/master/OData/test/E2ETest/WebStack.QA.Test.OData/DateAndTimeOfDay/DateAndTimeOfDayTest.cs#L169-L171
and
https://github.com/OData/WebApi/blob/master/OData/test/E2ETest/WebStack.QA.Test.OData/DateAndTimeOfDay/DateAndTimeOfDayTest.cs#L208-L212
Besides, there's a simple tutorial you can refer to:
http://odata.github.io/WebApi/#04-04-date-and-timeofday-support
Thanks. Hope it can help.

How can I add several months to a date coming from a date form field?

With DateJS, you'd add e.g. six months to the current date like this:
Date.today().addMonths(6);
However, I need to add 24 months not to today's date, but to a date which a user has typed into a date field. So the today() should in principle be replaced by something like this.getField('begin_date').value.
The result shall be written into another data form field.
I tried hard, but couldn't make it. Can anyone help me out?
Providing the input value is a textual representation of a date, you need to convert it into a Date object at the first place. Then you can work with it as you want.
DateJS has a pretty smart parse() function which does exactly that, so you'd achieve it like this:
Date.parse(this.getField('begin_date').value).addMonths(24)
When a specific date format is needed, like DD.MM.YYYY commonly used in Europe, you can use parseExact() and specify the format. Like this:
Date.parseExact(dateToParse, 'dd.MM.yyyy') // leading zeroes required; parses 01.04.2014 but not 1.4.2014
Date.parseExact(dateToParse, 'd.M.yyyy') // leading zeroes not required; parses both 01.04.2014 and 1.4.2014
Here is a solution that I found for my problem, using DateJS as well:
start = this.getField('begin_date').value;
var d1 = util.scand("dd.mm.yyyy", start);
var myDate = new Date(d1);
result = myDate.addMonths(24);
This works pretty fine, also spanning leap years, except for the 28th of February, 2014/2018/2022 ... ; the result then will be the 28th of February, 2016/2020/2024 ... and not the 29th of February 2016/2020/2024... In these cases it's up to the user to accept the 28th or to manually change the date to the 29th.

Problems passing a date from a form into Docmd.openreport

I am pulling my hair out because I just don't see what is wrong here. I suspect it is a simple/stupid error but just can't see it. I am a relatively inexperienced VBA programmer but I like to think literate enough to get by with most programing langages.
Problem
I have a simple Invoicing system. One of the reports I want to be produced is a report of all the invoices issues after a specific date.
To that end I have created a report "All invoice query" which uses a query of the same name to generate a summary of all the invoices in the system and deliver a one line summary (date, amount, paid flag)
I wanted to amend this so that I can limit the printout to invoices after a particular date.
I created a field (text box; format shortdate) in my dashboard to hold the date and a button to 'run' the report
The button calls the procedure
Private Sub ButtonAfterDate_Click()
DoCmd.OpenReport "All invoice query", acViewPreview, , "[Invoice date] > #" & Me.Printdate & "#"
End Sub
This produces a report with all of the invoices in the system (i.e. no filtering)
If I go to the table where the data in held [Invoices] and copy the date from there and paste it into the form control the report starts working and the report only displays the invoices after the date.
I have checked that my form control is set to shortdate, I have tried typing the date and selecting it with a date picker (no difference still fails to filter)
In desperation I have tried changing the control to a list box that uses a query to lift the dates from the Invoice table (however that failed so went back to my original control button and field to hold the date (with date picker)
In summary
If I copy and paste a date from the table into the form control the OpenReport behaves as expects and filters
If I type the date or use the date picker to put the date in the form control OpenReport ignores any filtering and displays all the invoice summaries.
It seems like a data type problem but am at a loss what to try next
Thanks in advance for any help
I have found the answer. I didn't realise that the where clause of the Docmd.OpenReport must have any dates in US format i.e. mm/dd/yyyy I am in the uk and the localisation on windows (and indeed uk practice) enters this as dd/mm/yyyy
After doing some research I found a function to re-write the date from uk to us format then put the amended string in the where clause.
I found the code to modify the date here :http://bytes.com/topic/access/answers/511395-dates-where-clause
but for convienience:
Public Function FixDate(strDate As String)
Dim D1 As Integer, D2 As Integer
D1 = InStr(strDate, "/")
D2 = InStr(D1 + 1, strDate, "/")
FixDate = CDate(Mid(strDate, D1 + 1, D2 - (D1 + 1)) & "/" _
& Left(strDate, D1 - 1) & "/" _
& Mid(strDate, D2 + 1))
End Function
posted by Randy Harris
tech at promail dot com
I then modify my event procedure to use this code:
Private Sub ButtonAfterDate_Click()
Dim mydate As Date
mydate = Me.Printdate
FixDate (mydate)
DoCmd.OpenReport "All invoice query", acViewPreview, , "[Invoice date] > #" & mydate & "#"
End Sub
And it works!
Thanks to all those who looked and had a think about it and I hope that it helps someone else.