intervals

Calculating days per month between interval of two dates

限于喜欢 提交于 2019-12-01 18:12:01
I have a set of events that each have a start and end date, but they take place over the scope of a number of months. I would like to create a table that shows the number of days in each month for this event. I have the following example. event_start_date <- as.Date("23/10/2012", "%d/%m/%Y") event_end_date <- as.Date("07/02/2013", "%d/%m/%Y") I would expect to get a table out as the following: Oct-12 8 Nov-12 30 Dec-12 31 Jan-13 31 Feb-13 7 Does anybody know about a smart and elegant way of doing this or is creating a system of loops the only viable method? Jochem This is not necessarily

MySQL DATE_ADD usage, 5 day interval

我们两清 提交于 2019-12-01 15:08:11
I'm trying to select the order total sum ($) and invoice count over a 5 day period in a single query. I can't seem to get this to happen though. The current query I have is here... SELECT COUNT(id) as invoice_count, SUM(orderTotal) as orders_sum, UNIX_TIMESTAMP(created) as created FROM ids_invoice WHERE DATE_ADD(created, INTERVAL +1 DAY) AND userId = 23 LIMIT 5' I'm not entirely sure DATE_ADD is the right function I'm looking for. Currently I'm getting.... Array ( [0] => Array ( [invoice_count] => 420 [orders_total] => 97902.90 [created] => 1252596560 ) ) Array ( [0] => Array ( [invoice_count]

MySQL DATE_ADD usage, 5 day interval

时间秒杀一切 提交于 2019-12-01 14:51:13
问题 I'm trying to select the order total sum ($) and invoice count over a 5 day period in a single query. I can't seem to get this to happen though. The current query I have is here... SELECT COUNT(id) as invoice_count, SUM(orderTotal) as orders_sum, UNIX_TIMESTAMP(created) as created FROM ids_invoice WHERE DATE_ADD(created, INTERVAL +1 DAY) AND userId = 23 LIMIT 5' I'm not entirely sure DATE_ADD is the right function I'm looking for. Currently I'm getting.... Array ( [0] => Array ( [invoice

MySQL increment user variable when value changes

大城市里の小女人 提交于 2019-12-01 08:19:47
I have a table consisting of groups of, for example, five rows each. Each row in each group possesses a date value unique to that group. What I want to do in my query, is go through the table, and increment a user variable (@count) when this date value changes. That's to say, @count should equal the group count, rather than the row count. My current query looks like this, in case you're wondering: SELECT @row := @row +1 AS rownum, date FROM ( SELECT @row := 0 ) r, stats Thanks a lot. What about something like this? SELECT (CASE WHEN @date <> date THEN @row := @row +1 ELSE @row END) AS rownum,

How to set SQL to find records from last sunday to this sunday (1 week)

为君一笑 提交于 2019-12-01 05:54:01
This is similar to what I have now, which is: SELECT COUNT(author) FROM `posts` WHERE `date` >= DATE_SUB(CURDATE(), INTERVAL 1 WEEK) AND author='FooBar' This will give me a count of how many times an author has posted in the past 1 week. I want to instead have it so if I am to run the program on Sunday at 5:30 PM to look for posts from last Sunday 12:00 AM to this Sunday 12:00 AM. Likewise, if I forget to run it on Sunday and it's monday now. I still want it to run from last Sunday 12:00 AM to the Sunday that just past 12:00 AM Edit: I have done what I needed using PHP to form the correct SQL

Create binned variable from results of class interval determination

最后都变了- 提交于 2019-12-01 05:53:23
I want to create a binned variable out of a continuous variable. I want 10 bins, with break points set from whatever results from a jenks classification. How do I assign each value to one of these 10 bins? # dataframe w/ values (AllwdAmt) df <- structure(list(X = c(2078L, 2079L, 2080L, 2084L, 2085L, 2086L, 2087L, 2092L, 2093L, 2094L, 2095L, 4084L, 4085L, 4086L, 4087L, 4088L, 4089L, 4091L, 4092L, 4093L, 4094L, 4095L, 4096L, 4097L, 4098L, 4099L, 4727L, 4728L, 4733L, 4734L, 4739L, 4740L, 4741L, 4742L, 4743L, 4744L, 4745L, 4746L, 4747L, 4748L, 4749L, 4750L, 4751L, 4752L, 4753L, 4754L, 4755L, 4756L

Java: How do I store a timeline/schedule, location full or empty from time x to y (interval)?

懵懂的女人 提交于 2019-12-01 05:41:36
Some brief background: I have a java app that's used to see when certain locations (classrooms) are in use or not. The user puts a location identifier into a search box and the program displays any events (classes) matching. The app will display all the pertinent information (class name, room #, professor name, day of week, time of class), classes that are in-session (or soon to be) are color-coded so you can tell at-a-glance if there's anything coming up. The data comes from an html page I'm scraping from (I don't have SQL access). Everything to this point works, I'm using JavaSwing for the

php - How To Convert 1 day To Seconds

…衆ロ難τιáo~ 提交于 2019-12-01 05:31:32
I am creating a form to set publish interval and want to sum all of the submitted values into seconds. The form consist of fields to determine seconds, minutes, hours, day and so on. I am collecting the submitted values to string by giving date attributes, like second, minute etc. For example: $second second $minute minute $hour hour So if user input 1 in input field to determine the interval in day and 30 in minute , then my code will convert it to string 1 day and 30 minute . My questions: 1- How can I convert 1 day and 30 minute string into seconds so they can be summed up into correct

Select records by time in interval between 12:00:00 and 18:00:00 on every day

跟風遠走 提交于 2019-12-01 05:22:33
问题 I've tried to select all records in a table with the timestamp in the dateformat 2011-08-01- 12:00:00 Using the following code: SELECT f.`fly_reg`, RIGHT(f.`start_tid`,8) AS st, f.`start_hight` FROM vbsk_dk_02.fab_master_flyvedata f Where st between 12:00:00 AND 18:00:00 But can't get it to work 回答1: You've got two issues here: You can't refer to column aliases in the where clause. Instead, you have to repeat your calculation in the where clause Use the TIME() function to extract the time

How to make calculation on time intervals?

只谈情不闲聊 提交于 2019-12-01 02:22:46
I have a problem ,i solve it but i have written a long procedure and i can't be sure that it covers all the possible cases . The problem: If i have a main interval time ( From A to B ), and secondary interval times (Many or no) (`From X to Y AND From X` to Y` AND X`` to Y`` AND ....`) I want to SUM all parts of My Main interval time (AB) out of secondary intervals in minutes in efficient and the least number of conditions (SQL server Procedure and C# method)? For Example : If my Main interval From 02:00 to 10:30 And say one secondary interval From 04:00 to 08:00 Now i want this result : ((04