Questions about performing arithmetic operations on dates and times.
Questions tagged [date-math]
129 questions
1
vote
1 answer
How to date stamp last Sunday's date
I'm looking to have a couple of dates stamped onto the spreadsheet on opening.
My current script is as follows:
Private Sub Workbook_Open()
'Automate start time on opening
With Worksheets("Time Recording Estimate")
If…

kitarika
- 175
- 1
- 12
1
vote
2 answers
How can I calculate dates in jQuery, and set an input date's value to that?
I have this html:
Which sets…

B. Clay Shannon-B. Crow Raven
- 8,547
- 144
- 472
- 862
1
vote
2 answers
Getting php to properly add days to date
I have a invoicing system that generates the next due date after the invoice is paid. My problem though is I want to generate the next invoice based on the date the last one was due, not when it was paid.
I'm familiar with adding days to the…

M David
- 127
- 7
1
vote
1 answer
Powerbuilder Date Math
How do I subtract 30 days from a date in PowerBuilder?
I have the following code that returns today's date in a parameter, but I need today - 30 days:
dw_1.setitem(1, "begin_datetime",
datetime(today(), Now()))

Jeff
- 8,020
- 34
- 99
- 157
1
vote
1 answer
Can't use variable in DateTime's modify() function. I'm getting an error: Object of class DateInterval could not be converted to string
I managed to dynamically load and compare several time values in PHP.
Right now I am stuck here:
$additional_time = $entry_start->diff($compare_from_timeformat);
$additional_time ->format("H:i");
$avaliabletime->modify('+1 hours');
I want to…

Gramrock
- 49
- 7
1
vote
2 answers
add days to the next/following month using php
I have a date in php using the date function
$date = date('Y-m-d');
I need to add certain number of days to the following month to show a deadline.
eg: if someone adds a job today with a 5 days, 2014-08-04 the deadline should be 2014-09-06
I was…

LiveEn
- 3,193
- 12
- 59
- 104
1
vote
2 answers
Remove Expired Records in solr query syntax
I'm having a solr query syntax issue (I think) with solr 1.4. I'm trying exclude expired records from a solr query. However if the record doesn't have an expiry record, i would like to bring that record back also. E.g.
To only get a list of record…

CraftyFella
- 7,520
- 7
- 47
- 61
1
vote
2 answers
Elegant way to set the DateTime to the latest business hour
I want to set an "As Of" value on a record reflecting the latest business hour available.
For example, let's say we define business hours as M-F, 9AM to 5PM. If I invoke this on a Thursday at 4:00PM, the "As Of" should be Thursday at 4:00PM;…

Jeremy Holovacs
- 22,480
- 33
- 117
- 254
1
vote
2 answers
How can you get the number of days since year 0 in PHP?
It's the equivalent of the MySQL to_days() function.
Is there a builtin PHP function that does this, or do I need to cobble something together?

jodonnell
- 49,859
- 10
- 62
- 67
1
vote
1 answer
Negative time in PHP
im calculating the hours worked by an employee and need to know if the employee have extra hours worked or if the employee doný work the total hours corresponding with his profile.
For example:
Day From_Hour To_Hour Hs_Worked Extra_time PHP_Return
…

Gonzalo Artur
- 35
- 1
- 8
1
vote
3 answers
Detect Saturday and Sunday and add x amount of days to Monday
I want it to automatically add days until Monday if someone choose Friday.
Imagine $leavefrom is 3-1-2014 which is Thursday, and $leaveto is 3-2-2014 is Friday. $totaldays are calculated based on the date. Therefore it is 2 days.

Furry
- 340
- 1
- 4
- 22
1
vote
5 answers
Dates and Math in PHP
I am granting paid members of a site the ability to share premium content with non-members for a period of 30 days. Here is what I am trying to accomplish:
First, the subscriber fills out a form to generate an email to their buddy, which generates a…
user2855168
1
vote
3 answers
how to get time period between two dates
I have two dates and i want to get the amount of time between them.
I try this:
$created_dt="2014-01-30 09:27:02";
$done_dt="2014-01-30 16:29:38";
$created_dt=strtotime($created_dt); //1391066822
$done_dt=strtotime($done_dt);…

user2706762
- 397
- 1
- 3
- 11
1
vote
1 answer
Delete every record from mysql table where the date field is NOT in the future
I want to delete every row from the database where the Submission field is not in the future. The date is stored this way:
09/10/2013
So, in this example i want to delete this record, because its already expired. This is where i…

passatgt
- 4,234
- 4
- 40
- 54
1
vote
2 answers
PHP get time difference in minutes
I looked around and nothing I saw quite worked with my database layout. Basically I need to take the current time, and a predetermined event time, and see if the current time is 10 minutes prior to the event time. This is my test file, it gets the…

salty
- 594
- 4
- 6
- 18