date-range

Insert “daterange” field value into PostgreSQL table through JDBC

主宰稳场 提交于 2019-12-10 13:32:12
问题 I have a table in PostgreSQL(9.3) with daterange field type. I can select this field like a String with JDBC, but I cannot Insert it in a table. What I've tried: PreparedStatement stm = conn.prepareStatement("insert into mytable (my_daterange_field) values (?)"); stm.setString(1, "[2014-01-02,2014-01-04]"); int i = stm.executeUpdate(); and I got: Exception in thread "main" org.postgresql.util.PSQLException: ERROR: column "my_daterange_field" is of type daterange but expression is of type

How to get all weekends within date range in C# [closed]

拟墨画扇 提交于 2019-12-10 10:39:15
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . I am just wondering if there is a simple way or framework to to get all weekends within date range in C#? Is it possible to do with LINQ as well? Any clue? Thank you! 回答1: If you make a way to enumerate all days, you can use linq to filter to weekends: IEnumerable<DateTime>

Set dates for jQuery Date Range Picker from input values

人盡茶涼 提交于 2019-12-10 10:35:25
问题 https://github.com/longbill/jquery-date-range-picker I have everything working quite well but I can't seem to get the picker to use the default values that I set in the . There are two inputs, a start date and end date. I have a value="" with a date in both which should be the default date for the datepicker. Then the user has the ability to change those dates. I've played with a few different ideas but I can't get anything to grab the input's value attribute. Any insight would be appreciated

Prevent inserting overlapping date ranges using a SQL trigger

怎甘沉沦 提交于 2019-12-10 03:41:37
问题 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.

Ruby's range step method causes very slow execution?

烂漫一生 提交于 2019-12-09 17:52:16
问题 I've got this block of code: date_counter = Time.mktime(2011,01,01,00,00,00,"+05:00") @weeks = Array.new (date_counter..Time.now).step(1.week) do |week| logger.debug "WEEK: " + week.inspect @weeks << week end Technically, the code works, outputting: Sat Jan 01 00:00:00 -0500 2011 Sat Jan 08 00:00:00 -0500 2011 Sat Jan 15 00:00:00 -0500 2011 etc. But the execution time is complete rubbish! It takes approximately four seconds to compute each week. Is there some grotesque inefficiency that I'm

Querying with nHibernate where todays date is between publishDate and Expiry date

早过忘川 提交于 2019-12-09 11:29:32
问题 I am trying to figure out how to best query in NHibernate so that the returned results are between for entries where todays time is >= PublishDateTime and <=ExpiryDateTime The expiry date can be null so I need to allow for that. I found a couple of examples here and here but they seem to work in a different way and accept 2 values and compare to one DB field. I want the other way wrong really. Query so far: var query = _session.CreateCriteria<Message>() .AddOrder(Order.Desc("PublishedDateTime

django aggregation to lower resolution using grouping by a date range

孤人 提交于 2019-12-09 03:23:23
问题 horrible title, but let me explain: i've got this django model containing a timestamp (date) and the attribute to log - f.e. the number of users consuming some ressource - (value). class Viewers(models.Model): date = models.DateTimeField() value = models.IntegerField() for each 10seconds the table contains the number of users. something like this: | date | value | |------|-------| | t1 | 15 | | t2 | 18 | | t3 | 27 | | t4 | 25 | | .. | .. | | t30 | 38 | | t31 | 36 | | .. | .. | now i want to

Negative dates in SQLite

倾然丶 夕夏残阳落幕 提交于 2019-12-08 13:46:19
问题 Newly compiled SQLite displays a strange behavior concerning the date/time functions. Do you have any idea what is going on and how to fix it? $ date Mon Mar 8 14:52:11 CET 2010 $ ./sqlite3 TEST0 SQLite version 3.6.22 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> SELECT date('now'); -4713-11-24 sqlite> SELECT strftime('%s','now'); -210866760000 sqlite> select datetime( -210866760000 , 'unixepoch'); 1970-01-01 00:00:00 The version is SQLite 3_6_22 for ARM

Showing dynamic rates for all dates using jquery ui calendar

邮差的信 提交于 2019-12-08 13:27:16
问题 In a Car Rental Website Reservation System, i am using jquery ui calendar as a date range picker for "From Date" and "To Date" selection. I want to show dynamic rates for different dates as shown in figure. Please let me know how i can do that ? <input type="text" id="booking-from" name="booking-from" /> <input type="text" id="booking-to" name="booking-to" /> $( "#booking-from" ).datepicker({ defaultDate: "+1w", minDate: 0, firstDay: 0, dateFormat: 'dd-mm-yy', changeMonth: true,

Get max bookings count in range

廉价感情. 提交于 2019-12-08 07:05:06
问题 I have a ParkingLot model. Parking Lots have a number of available lots . Users can then book a parking lot for one or more days. Hence I have a Booking model. class ParkingLot has_many :bookings end class Booking belongs_to :parking_lot end Simplified Usecase ParkingLot Given a parking lot with 5 available lots: Bookings Bob books a place from Monday to Sunday Sue makes one booking each on Monday, Wednesday and Friday Henry books only on Friday. Since the weekend is busy, 4 other people book