Get minutes from a time field in a CakePHP form? - forms

I'm using CakePHP to build a mixed martial arts (MMA) website. I have a form to add matches, and one of the fields is for rounds length, which is in minutes, and which I'm storing in my database as a TIME value.
In my form, I only want the minutes portion of the value editable. I've tried creating a field with the name Match.rounds_length and setting the type to number, but can't get it to populate with the minutes value.
Here's what I have currently:
$this->Form->input('Match.rounds_length' => array('type' => 'time'));
I did find this page in the CakePHP online documentation: http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#field-naming-conventions. But I can't seem to get it to work in my setup.
Could someone familiar with CakePHP tell me how to create just an open text field that the user can specify the number of minutes a round should last that would then be saved as a time value in my database, and populated properly in my edit form?

I tried the following. And it worked.
echo date('i', strtotime('00:05:00'));
date() format specifiers list will help you to achieve the same as you mentioned in your question.
Kindly ask if it not worked for you.

Related

MS Access: Make Form show only records from last 48HS

I am using MS Access and I have a table called tblLogs, it contains all the logs and a field called logDate. I have created a form in which I need to show the data from tblLogs, but only the records from the last two days. My question is: what are my options?
I've been doing some research and tried making a query which retrieves the data I need from last 2 days, but after doing it I realized there wasn't an easy way to bind query content to a Control (a text box in this case). Another option that came to mind was somehow setting an automatic filter that is triggered when you open the form (don't know how to do it yet), but I don't know if that would be convenient.
So, I'm all ears guys
In the form properties set Filter On Load to Yes and Filter to
logDate >= DateAdd('h', -48, Now())

Invalid Date error when entering record on Sharepoint list Datasheet view

I have a list on Sharepoint 2013. I've often use the Edit this list link to make bulk changes to the list in datasheet view with no problem. Last week I had a bunch of new records I needed to add so decided bulk copy and paste from Excel would be best. However, I get the error "Invalid date/time value. A date/time field contains invalid data. Please check the value and try again." The field is Date/Time with Date only display. The format I copied in was mm/dd/yyyy, which is how it's displayed (I realize there's a difference between formatting and display). In the past I've used this format to update dates with no problem. I've tried manually changing the date to other formats like yyyy/mm/dd (or with dashes -), and using the date picker and nothing works. I can add a new item using the form and no problem with the date. It's only happening in datasheet view.
I have 70+ records to add and would rather not have to open a new form for each one (I'm only adding info to 7 of the fields, and I first only pasted a couple records to make sure there were no issues). Are there any recent known issues about date fields in datasheet view? It's a pretty straightforward thing, no calculations are being used, I'm not trying to connect to another service, or use outlying dates (dates are all 2017) so I'm perplexed why this is an issue now and not before. Any thoughts on this would be appreciated.
Found the issue. I had another date field I was not using in that view that for some reason the default value had been set to Calculated field with a value of 1/1/1111. No idea how that got there but I removed that and set the default value to None and now the problem is gone. I found it by creating a new view with every date field in the list and systematically copying a date into each field (in bulk edit) and trying to save after each one until it saved. Then I checked the settings for the field that I was able to save with.

Executing a Find Script with a range of dates as the criteria

Im trying to create a Find Script on two date selection fields (Drop Down calendars) that automatically run each time the field is updated/changed (I understand this part aka script triggers) and the report will show the results that contain dates listed between the range selected.
Please Keep in mind that I'm quite new to this so please correct me where you think I could improve is you find or see anything else that appears to be wrong. Anyways, here is the Layout for my report where the selection fields and results field are highlighted.
Here is the script code I've created and I'm trying to use.
"Pre Construction::Bid Date" ≥ "Bid Date Search::Start Date" & "Pre Construction::Bid Date" ≤ "Bid Date Search::Start Date"
Here is the error I get when I try to add/save this in/under the perform find -> specify dialog box.
Ive tried and set all the fields to use the exact same date layout and format (the xx/xx/xxxx) and ive still had no luck in created this type of search. Im hoping someone will be able to help me fix this or offer other solutions as to how I could go about creating this. Thank you all
There are two problems with your attempt:
First, you cannot use references to fields in a find request.
Next, to find records within a specified range, you must use the range operator (two or three periods).
Now, you could populate variables with the range boundaries and use these in the find request instead of the fields, but it is much more convenient to skip stored find requests altogether and do simply:
Enter Find Mode [ ]
Set Field [ Pre Construction::Bid Date; Bid Date Search::Start Date & ".." & Bid Date Search::End Date ]
Perform Find [ ]
Of course, we are assuming that the Start Date and End Date fields are global fields.

MS Access calculated fields changing to "#Error"

I currently have a form that runs off of a query and everything works swimmingly, or at least it appears. I have three fields in question: an ID field, a Client Name field, and an Age field. The age field is actually the client's age at the signing of the quote, so it is a calculated field using the date of the quote and the client's DOB.
The age calculation works perfectly upon first look. The reason the ID and name fields are in question are because when I double click them it opens a form, which yet again works fine. The problem is when I exit those forms and come back to the original form.
The age field of whatever record I was on changes to "#Error" instead of what it was displaying. If i click on a different record in the form then that age field changes to "#Error" as well. This seems to happen every time and I have no clue why.
Has anyone solved an issue similar to this or have an idea on how to solve it?
Thanks in advance!
Update: I changed it to open a report rather than a Form and the issue is still there.
The calculation in question: Int(([effectiveDate]-[dateOfBirth])/365.25)
Try calculating age this way:
DateDiff("yyyy", [dateOfBirth], [effectiveDate]) + ([effectiveDate] < DateSerial(Year([effectiveDate]), Month([dateOfBirth]), Day([dateOfBirth])))
Using this method takes the difference in years between your date of birth and the effective date, taking into account that the person's birthday may not have passed yet by that date.
Basically the first part gets the years and the second part either adds 0 for false or adds -1 for true if the effective date is LESS than the birthday for the effective year (meaning it hadn't passed yet)

SUMIFS with multiple criteria, one of which is a single day

I'm trying to get a formula that will break down the amount of times a user enters a contest each day.
I'm pretty new to this whole thing, basically putting it together using google to figure out the code I need to use/modify. Explaining why something works would be greatly appreciated so I can use it elsewhere!
Here's a dummy of the form I'm banging my head against.
I would like the form to be reusable, so on the Sorted form I have a date key that automatically fills out the week when you choose the first day. Because of this, I would like each formula to refer to this date key, instead of manually typing the google equivalent of 'February 1st, 2015' into the formula.
I've tried to use the SUMIFS formula, and I've run in to a few errors.
Apparently both pages have to be the same amount of rows, otherwise I get an 'Array arguments to SUMIFS are of different size'. I didn't want my 'sorted' sheet to be 1761 rows long, since all of the duplicate names will have been condensed and I wanted it prettier. Nuts to that! Guess I can hide the rows? Is there any other solution?
It looks like this works:
=SUMIFS(Entered!E3:E1000, Sorted!E3:E1000, Sorted!$E3, Entered!A3:A1000, date(Sorted!$C7))
Where entered!E: is the number of entries, sortedE: is the list of usernames, and E3 is the specific one I'm looking for. Then EnteredA3 is the list of dates and time, and Sorted!C7 is the specific date I'm looking for. I don't get any results!
If I click on my C7 and sorted!A, the little calender pops up, which means they are dates (I think?). One includes the hours:minutes:seconds and the other doesn't, which I think is my problem. I would like to have sorted!C7 be the entire day, and filter out all of those entries.
This is taking information entered via a google form which I won't have control of, so I can't really change the H:M:S additions to the date column.
Thinking ahead to day 2 and onwards, will the same formula work when sorted!C10 is C$7$+1? Is it not a date anymore?
I would also like to add up the amount of daily entries, in sorted!S7 and below. I've tried wrapping both the column of dates and the date from my day key in the date() thing, but it doesn't seem to work either.
=SUMIF(date(Entered!A3:A),date(Sorted!C7),Entered!E3:E)
It gives me a '1', and I have no idea where that comes from.
I haven't been able to find much about the google SUMIFS function, mostly how to replicate it from before it was a thing.
And for even MORE complexity:
I was wondering if it is possible to have UNIQUE find the IDs in entered!C, and return all the associated usernames. That pesky angelo changed their username to 'pants' midway through the contest, and I'd like to be able to see both names and add up both 'angelo' and 'pants' entries in the same line in my formulas.
I feel like I'll need a few hidden columns that have the UNIQUE ID number and the associated usernames that I pull into my Sorted!Username column, but I don't know how to search the IDs to find the different usernames.
I tried to google that, but I have no idea what I'm googling.
Whewph! That is a lot of questions, thanks for any help!
Too long for my taste, but you might try:
=sumifs(Entered!E:E,Entered!A:A,">="&$C$7,Entered!A:A,"<"&$C$7+1,Entered!B:B,$E3)
in Sorted!F3 and copied down to suit.
Oh my goodness, you are a hero!
My final code wound up being:
=IF(ISBLANK(Sorted!$E3)=TRUE, "", sumifs('Entered'!$E:$E,'Entered'!$A:$A,">="&$C$7,'Entered'!$A:$A,"<"&$C$7+1,'Entered'!$B:$B,$E3))
I changed the start and end points by making $C$7 into $C$7+1, and the ending one into +2. (In case anyone else is looking at this answer.)
I'm super pleased that it worked!
Using this I managed to add up each of the daily entries, just by adding up the columns they were in.
I gave up on the UNIQUE idea, if someone changes their username during the contest, then they can add up the two rows themselves.
Thanks again! I'd upvote you, but I can't yet.