date-range

How to extract every Monday and every fortnightly Monday from a range of two dates in PHP?

前提是你 提交于 2019-12-05 15:30:49
I'm using the infamous jQuery UI's Datepicker, and in my form I select a range of two dates. First represents the starting date and the other represents the end date. What I need now is the algorthm, some tips and directions or helpers for calculating every Monday between these two dates. For instance: start: 2011-06-01 end: 2011-06-30 Should extract me these 4 (four) dates witch lay on Mondays: 1st: 2011-06-06 2nd: 2011-06-13 3rd: 2011-06-20 4th: 2011-06-27 How could I achive this? And also, I'd need it for every fortnightly Monday: Result for fortnightly should be: 1st: 2011-06-06 2rd: 2011

Select a date range from a timestamp column

邮差的信 提交于 2019-12-05 12:29:18
Currently my table has a column to store date and time. The data type of that column is timestamp without time zone . So it has values in the format '2011-09-13 11:03:44.537' . I need to retrieve rows with respect to the date. If I use: select * from table where mdate >= '2011-09-13 11:03:44.537' and mdate <= '2011-09-12 11:03:44.537' it will provide the values which are in between '2011-09-13 11:03:44.537' and '2011-09-12 11:03:44.537'. But if I am going with: select * from table where mdate >= '2011-09-13 00:00:00.0' and mdate <= '2011-09-12 00:00:00.0' without date, month and seconds, It is

Prevent inserting overlapping date ranges using a SQL trigger

倾然丶 夕夏残阳落幕 提交于 2019-12-05 05:38:46
I have a table that simplified looks like this: create table Test ( ValidFrom date not null, ValidTo date not null, check (ValidTo > ValidFrom) ) I would like to write a trigger that prevents inserting values that overlap an existing date range. I've written a trigger that looks like this: create trigger Trigger_Test on Test for insert as begin if exists( select * from Test t join inserted i on ((i.ValidTo >= t.ValidFrom) and (i.ValidFrom <= t.ValidTo)) ) begin raiserror (N'Overlapping range.', 16, 1); rollback transaction; return end; end But it doesn't work, since my newly inserted record is

% of participants that are retained during six months

夙愿已清 提交于 2019-12-05 04:16:42
I am a school teacher very new to MS SQL server. Everyone is suggesting to try this site out. Here goes! I am trying to write queries to test different types of outcome measures for the participation in a academic program. There are several different ways to calculate this outcome measurement I would like to try. The outcome which I am trying to Calculate is: What is the % of participants that are retained during six months of the program? I am testing different ways to define participant and different time ranges. There are 4 queries I am trying to produce. Unfortunately, I have to use for

SQL - Count number of itemactive within a date rate

你。 提交于 2019-12-05 02:15:28
问题 I have a dataset of Resources , Projects , StartDate and EndDate . Each Resource can be utilised by multiple projects. I want to get a count of the number of projects that are using a resource in each quarter. So if project starts in Q1 of a particular year and ends in Q3 that year, and project2 starts in Q2 and ends in Q3, I want to get a count of 2 projects for Q2, since during Q1 both project1 and project2 were active. Here is my dataset: create table Projects (Resource_Name varchar(20)

Compare multiple date ranges

依然范特西╮ 提交于 2019-12-04 20:20:52
I am using iReport 3.0.0, PostgreSQL 9.1. For a report I need to compare date ranges from invoices with date ranges in filters and print for every invoice code if a filter range is covered , partially covered , etc. To complicate things, there can be multiple date ranges per invoice code. Table Invoices ID Code StartDate EndDate 1 111 1.5.2012 31.5.2012 2 111 1.7.2012 20.7.2012 3 111 25.7.2012 31.7.2012 4 222 1.4.2012 15.4.2012 5 222 18.4.2012 30.4.2012 Examples Filter: 1.5.2012. - 5.6.2012. Result that I need to get is: code 111 - partialy covered code 222 - invoice missing Filter: 1.5.2012.

Mongodb Subdocument Date Range Returns Wrong Results

我怕爱的太早我们不能终老 提交于 2019-12-04 19:45:33
first time in Stackoverflow. I'm trying to run a date range query on an array collection but Mongo Shell returning irrelevant documents witch doesn't match my criteria. It doesn't matter i'm doing the query trough PHP drivers, Doctrine Mongodb Query-builder or Mongo Shell. Here is my query: db.deals.find( { "total_sold.created_at": { $gt: new ISODate("2014-03-05T00:00:00Z"), $lt: new ISODate("2014-03-05T23:59:00Z") } }).limit(1).pretty() And here is the result: { "_id" : "1241412fb99a11a0bc70032a2cb6059b", "total_sold" : [ { "some_field": "value", "created_at" : ISODate("2014-02-13T15:48:35Z")

jquery UI datepicker - disabling date ranges

房东的猫 提交于 2019-12-04 14:03:28
I'm struggling to get something working - I'm getting a 'Uncaught TypeError: Cannot read property '0' of undefined' error with the below and I can't figure out why! I'm trying to use the jQuery UI datepicker on a site for a holiday cottage to indicate availability and season (low, high etc). I have a function as a datePicker event to check if there's a booking for a date, and if not, I then go out to check which season we're in (In non-peak season bookings can be made on a Monday or Friday. In Peak season, it's Fridays only. ) I'm using a cms to generate some date arrays (via loops) that I can

Generating monthly timestamps between two dates in pyspark dataframe

依然范特西╮ 提交于 2019-12-04 12:48:20
I have some DataFrame with "date" column and I'm trying to generate a new DataFrame with all monthly timestamps between the min and max date from the "date" column. One of the solution is below: month_step = 31*60*60*24 min_date, max_date = df.select(min_("date").cast("long"), max_("date").cast("long")).first() df_ts = spark.range( (min_date / month_step) * month_step, ((max_date / month_step) + 1) * month_step, month_step ).select(col("id").cast("timestamp").alias("yearmonth")) df_formatted_ts = df_ts.withColumn( "yearmonth", f.concat(f.year("yearmonth"), f.lit('-'), format_string("%02d", f

Split date into several chunks ending by YYYY-12-31

爷,独闯天下 提交于 2019-12-04 10:54:19
df <- data.frame(group = c("a", "a", "b", "b"), start = c("2017-05-01", "2019-04-03", "2011-03-03", "2014-05-07"), end = c("2018-09-01", "2020-04-03", "2012-05-03", "2016-04-02")) Let's say I have the following df: group start end 1 a 2017-05-01 2018-09-01 2 a 2019-04-03 2020-04-03 3 b 2011-03-03 2012-05-03 4 b 2014-05-07 2016-04-02 I want to get it into this format, with each record split into starting date and 31/12 of that and subsequent years: group start end 1 a 2017-05-01 2017-12-31 2 a 2018-01-01 2018-09-01 3 a 2019-04-03 2019-12-31 4 a 2020-01-01 2020-04-03 5 b 2011-03-03 2011-12-31 6