Questions tagged [dateinterval]

Data type used for capturing a interval between two date objects. This is found in PHP, Swift, and likely other languages too.

Data type used for capturing a interval between two date objects. This is found in many languages including PHP and Swift (and likely other languages, too).

For more information, see:

221 questions
2
votes
1 answer

Define time intervals using day of week/month (ISO 8601?)

I want to define time intervals like: Each week, from Monday 12:00 a.m. to Sunday 11:59:59 p.m. Each day from 12:00 a.m. to 11:59:59 p.m. Each month from the first day of the month 12:00 a.m. to the last day of the month 11:59:59 p.m. Is this…
root66
  • 477
  • 5
  • 17
2
votes
0 answers

Sum of INTERVAL DAY in Oracle

I have a table TABLE4, with the COLUMN1 have the following values, 0 2:2:30.361000000 0 3:15:40.899000000 0 3:7:38.128000000 with the data type as INTERVAL DAY(2) TO SECOND(6) I need to add these times.I was trying to add this like, select…
Nidheesh
  • 4,390
  • 29
  • 87
  • 150
2
votes
2 answers

Datetime Add/Subtract Miscalculation

$datenow = new DateTime(); $dn = $datenow -> format("Y-m-d"); //2014-12-02 $yesterday = $datenow -> sub(new DateInterval('P1D')) -> format("Y-m-d"); //2014-12-01 $yestertwo = $datenow -> sub(new DateInterval('P2D')) -> format("Y-m-d");…
HDKT
  • 71
  • 1
  • 8
2
votes
1 answer

Use DatePeriod and DateInterval to get certain weekdays within a period of time

I need to get certain weekdays within a period of time. Weekdays can be only one ore more, e.g. only all Mondays or all Mondays, Tuesdays and Wednesdays. I would like to use DatePeriod together with…
gebeer
  • 703
  • 6
  • 8
2
votes
2 answers

PHP: define start date for interval

I am using the following lines to calculate a 4-week interval in PHP. This uses a fixed date ($calStart) as basis for the calculation and ends the interval with the last day of the selected year ($rangeEnd / $selYear) which works well so…
user2571510
  • 11,167
  • 39
  • 92
  • 138
2
votes
1 answer

PHP - Convert integer duration to formatted string

I have a form input that accepts time interval strings such as "1 day", "3 weeks", "2 months, 10 days" etc and converts them to integer representations of the total seconds, so "1 day" becomes 86400. Now I need to be able to retrieve the integer and…
Bobe
  • 2,040
  • 8
  • 29
  • 49
2
votes
1 answer

Calculate Average of DateInterval

I'm looking for a way to calculate the average total duration (in DateInterval form) of an event. I have the durations in DateInterval objects, but I need to sum those up and calculate their average. Solutions I've seen so far have me adding up the…
muttley91
  • 12,278
  • 33
  • 106
  • 160
2
votes
2 answers

PHP DateInterval select days of week every x weeks

I've written some code for entering recurring events. The trickiest part is a user can create an event and have it repeat on selected days of the week ever x weeks. For example, the user can select Mon,Wed,Fri and have it repeat every 3 weeks. Easy…
AdamP
  • 73
  • 1
  • 8
2
votes
1 answer

PHP & XML (PT) Time Format

I'm writing a PHP script to parse an XML file generated from software our company uses. The time format is formatted in such a way; I am wondering whether their is an easier way to parse the time. PT1H23M5S // This is the XML…
rossuhms
  • 25
  • 1
  • 4
2
votes
2 answers

Date Interval can return negative zero or positive zero how can I set a conditional statement on the result

Given the $interval is a DateInterval object following conditional statement is true whether the anniversary is within 1 year prior to the current date = 0 or the anniversary is within 1 year post the current date = -0. $interval =…
codepuppy
  • 1,130
  • 2
  • 15
  • 25
1
vote
2 answers

Splitting a start and end date by interval in PHP

Is there any function to split a start and end date into chuncks of $interval days (or months)? For example: $interval = new DateInterval('P10D'); $start = new DateTime('2012-01-10'); $end = new DateTime('2012-02-16'); $chunks =…
gremo
  • 47,186
  • 75
  • 257
  • 421
1
vote
1 answer

Power BI - SQL - between dates not working

I have connected Power BI to a datasource and querying it via sql queries in Power BI. Wants to add a WHERE clause to only include dates for a certain period, e.g. everything that has a date stamp of 30 days from today's date. In SQL server I would…
Luntas
  • 11
  • 1
1
vote
1 answer

R (dplyr): find all rows in row-specific range *WITH RESTRICTION*

I have a dataset where each row is identified by a hospitalization id. Each row contains information on the hospitalization id, the dates of admission and discharge, as well as the identification of the hospital where it took place and the physician…
PaulaSpinola
  • 531
  • 2
  • 10
1
vote
1 answer

Xcode error: Cannot use instance member 'selectedWateredDate' within property initializer; property initializers run before 'self' is available

I'm trying to figure out why I keep getting the following error using SwiftUI: Cannot use instance member 'selectedWateredDate' within property initializer; property initializers run before 'self' is available for my "dateInterval"…
izzieyo20
  • 13
  • 3
1
vote
1 answer

count, for a list of date, how many time intervals contains a date

I could not solve this issue even after looking at several answers on stack overflow. I have a dataset with a list of dates and a list of intervals. I need to find how many intervals contains a date, for that given date. I could find several…
mgreco
  • 23
  • 4