Questions about performing arithmetic operations on dates and times.
Questions tagged [date-math]
129 questions
0
votes
1 answer
Get Next Meeting Date fails using Linq query
I need to display the next Meeting Date from a table of meeting dates. Once a date passes as current, the next date is supposed to show up. I've searched for similar examples but no…

JustJohn
- 1,362
- 2
- 22
- 44
0
votes
1 answer
delete time based indices on elastic search older than 30 days using date math expression in JAVA gives indexNotExists exception
want to delete time based indices on elastic search older than some specific (let's say 30) days using date math expression in JAVA.
Trying to implement following approach in our spring boot application using Transaport Client but getting index not…

singla_02
- 23
- 6
0
votes
1 answer
Subtract months from a given date in Matlab
I need to subtract 21 months from a given date.
My solution as given below only takes me to the first month of the given year :(
[a,b,c]= datevec(date);
b= b-21;
datestr(datenum(a,b,c)) %--> 11-Jan-2011 (WRONG).
I want the answer to be…

Maddy
- 2,520
- 14
- 44
- 64
0
votes
1 answer
Using dateMath rounding to hour for elasticSearch query
The current time say is "2017-10-01T06:27:17+0000"
So to query to data less than equal to time "2017-10-01T06:00:00+0000"
I have date range query
"range": {
"entryDate": {
"lte": "now/h"
}
}
Would it…

user2368055
- 410
- 6
- 14
0
votes
0 answers
Solr 6 how to use dateRange math with localParam op
1) I have a dateRange type field in solr 6,
It contains date ranges.
2) following query will give all the matching record which has date range from 1st jan 2017 To 31st dec 2017.
fq={!field f=dateRange op=Contains}[2017 TO 2017]
3) Following 2…

vikram eklare
- 800
- 7
- 25
0
votes
1 answer
PHP date_diff DateInterval could not be converted
I am having a heck of a time trying to find the difference between two dates. I am getting a date out of a database and trying to compare it with the current date and time.
What I need is the number of hours between the two dates. If I format the…

Soren
- 797
- 5
- 15
- 32
0
votes
2 answers
What is the correct way to do date math in this TSQL Stored Procedure?
Here is my business case: I need to, based on the user's input of date values for "BegDate" and "EndDate" also determine two other dates. Specifically, I need to know:
Week1Begin (which is the value they enter for "BegDate")
Week2End (which is the…

B. Clay Shannon-B. Crow Raven
- 8,547
- 144
- 472
- 862
0
votes
2 answers
If it has gone more than 3 days since timestamp, then do action
I have a specific timestamp stored in $user_timestamp, which could be for example 1421942631. And I have the current timestamp stored in $current_timestamp.
I want to compare the timestamp in this variable with the current timestamp and check if it…

Henrik Petterson
- 6,862
- 20
- 71
- 155
0
votes
1 answer
How to get 1 day started from today specific timestamp plus 24 hours
Currently I've used this code to get 1 day started from current timing of today plus 24 hours:
$daysago = date("Y-m-d H:i:s",strtotime(date('Y-m-j H:i:s')) + (1 * 24 * 60 * 60)); //Today + 1 day
How can I fixed the timestamp so for example the…

Resolution
- 759
- 1
- 7
- 18
0
votes
1 answer
PHP - Compare date to string regardless of timezone
I have a card expiry info passed to me as:
$date = '2014-12-22';
$hour = '19';
$minute = '30';
and I need to figure out if access can be granted based on the door location's current date and time each of which is in different timezone. The script…

Kate
- 712
- 3
- 6
- 23
0
votes
1 answer
Time deference between two date("F j, Y") dates in php
i have a problem to get month difference between two dates in months.
$d1 = date_create('January 1, 2013');
$date = date("F j, Y");
$d2 = date_create($date);
$dif = date_diff($d1, $d2);
//echo $dif->format('%y years');
echo $dif->format('%m…

Adeel Gill
- 353
- 4
- 19
0
votes
1 answer
Can't implement this timeAgo functionality in a PHP Loop
I'm trying to get PHP to show me some timeago functionality. I am looping through the results from a Mysql table where there is a column name called "aplicationdate" the format is "Y-m-d" in the database.. But it just shows me some negative large…

Cesar Downs
- 3
- 3
0
votes
1 answer
I want to be able to resample my time series data for the daily mean
I want to be able to resample my time series data for the daily mean. I have code for this, however the file I want to resample (an output file from a model) has time(d) where the days are numbered 1 to infinity rather than a date. Also, if rainfall…

dandan qin
- 7
- 1
0
votes
3 answers
PHP date_diff returns unusual warning
There are many questions that were asked on date_diff PHP function. But mine seems a bit different as I get a rather unusual result. Below is the code I have:
$today = date( 'd-m-Y', strtotime( "now" ) );
$selectDay = date( 'd-m-Y', strtotime(…

sri
- 338
- 2
- 13
0
votes
1 answer
PHP strtotime date difference
I want to get the age of users.
I tried:
$dStart = strtotime('1985-10-24');
$dEnd = strtotime('2014-07-30');
$dDiff = $dEnd - $dStart;
echo date('Y',$dDiff);
But get 1998 instead 28, what would be the right code?

user3838972
- 331
- 1
- 5
- 10