Cakephp timeAgoInWords to stop at the first value - cakephp

I am using the timeAgoInWords function in cakephp and I would like to know if there is a way to stop at the first time value, here is what I mean.
I have this code so far...
echo $this->Time->timeAgoInWords($post['created'],array('accuracy'=>array('day'=>'day')));
And some of my posts have a date that says 5 days ago while some others have 1 week, 5 days ago
How can I get all instances to stop at the first value so that 1 week, 5 days ago will just say 1 week ago
Keeping in mind that later on that some 1 week item may say 1 month ago instead of 1 month, 2 weeks, 7 days ago

Just specify the accuracy of each possible states :
accuracy'=>array('day'=>'day','week'=>'week','month'=>'month','year'=>'year')

Related

Trying to calculate the number of days since 1/1/1900 and the DateDiff function is off

I am trying to calculate the number of days that have passed between 1/1/1900 and 5/1/2019.
I have tried this using several dates and get the same out come.
The value returned is 2 days off.
--
-- calculate the number of days between 1/1/1900 and 5/1/2018
--
SELECT DATEDIFF(DAY,CONVERT(DATE,'1/1/1900'),CONVERT(DATE,'5/1/2018'))
Expected Result: 43221
Actual Result: 43219
Thank you for your help!
DATEDIFF returns the number of days between the two dates. So if you want 1900-01-01 to be numbered as day 1, then you must add 1 to any difference you get from DATEDIFF. In Excel, day 0 is 1899-12-31.
Secondly, Excel treats 1900 as a leap year, and has a 29-Feb-1900 (day 60 in the Excel numbering system iirc). This was a holdover from Lotus 1-2-3 which originally used a simplified algorithm for leap years (treating every year divisible by 4 as a leap), and remains for backward compatibility
If you combine these two faults, these account for your off-by-two results.

Last Activity > 7 Days Ago Report

I need to generate a report that shows activity on all accounts, were the last activity is greater than 7 days ago, thus not showing accounts that have had activity in the past 7 days.
I know this can be hard set when building the report, but I need this to update for the current day each time it is run. I don't wont to have to edit report everyday.
Wouldn't it be where DateField > LAST 7 DAYS since report support relative days such as LAST WEEK or LAST FY or YESTERDAY etc

How to get the last 7 Days Dates in SSRS

I'm having a Report where I need to display the dates of last 7 days.
As shown below
Sun, Mon etc... are hard coded and the Dates are written in Expression
For example,
If today is Wednesday I need to show the Dates till last Tuesday.
If it is Thursday I need to show the Dates till last Wednesday.
How to retrieve the dates information and display below the corresponding days.
To get last seven days date you can do something like below in each expression,
To get Days in Header
=WeekdayName(weekday(Parameters!TodaysDate.Value)) --Tuesday
=WeekdayName(weekday(DateAdd("d",1,Parameters!TodaysDate.Value))) --Wedneday
Same for others too... Just by increment/decrement by 1.
To get Days Date in Data
=Format(Parameters!TodaysDate.Value,"dd-MMM-yyyy")
=Format(DateAdd("d", 1, Parameters!TodaysDate.Value),"dd-MMM-yyyy")
Same for others too... Just by increment/decrement by 1.
Here TodaysDate would be parameter date or Now() Date.
I have given demo of incremental one, you can change it as per your condition. I think you need to use decrement here. So Instead of 1 you need to use -1.
This will give you output like below,

SOLR date range query for multiple years

I need to implement SOLR date ranges and trying to understand the following 2 conditions from SOLR wiki -
pubdate:[NOW-1YEAR/DAY TO NOW/DAY+1DAY]
createdate:[1976-03-06T23:59:59.999Z/YEAR TO 1976-03-06T23:59:59.999Z]
Im really concerned about the "/" operator within the date ranges..
Can someone explain ?
/DAY simply means: use 00:00:00 of that day. Without /DAY, it would be the current time minus 1 year. For the upper boundary, the NOW/DAY+1DAY means: use today, 00:00:00 and add 1 day, which results in tomorrow, 00:00:00.
With /YEAR, it is basically the same: it goes back to January, 1st, 00:00:00 of that year.
You can see this yourself by using debugQuery and taking a look at the timestamps in the querystring.

Time series ordering

I have a 200 data files to process. I need a solution for one of the files and I would do same for the rest of the files. It is a typical daily time series problem.
My rainfall data is arranged thus: 1990 to 2011 as years, under each year are 12 months, and in front of each month are 29 or 30 or 31 days depending on the month.
My problem is to take all the days in each month and place them beneath that month and for each year. The result will be two column vectors; one for dates and one for rainfall on each day, in each month in each year.
Thanks in advance.
Asong.
my data is shaped as:
1960 1 2 3 4 5 6 4
1961 1 2 3 4 5 6 4
and I want it to be 1960
1
.
.
N
1961
1
.
.
N
etc. as a column not row form.
I got the answer using reshape(a.',1,[]).
However, one problem remains. My data contains 31 days in all months. How can I tell matlab to delete last two or three days in February and one day in April and other months which are supposed to have 30 days but have 31 in my time series?

Resources