Displaying 20 results from an estimated 3000 matches similar to: "How to test if one range of dates overlaps another?"
2006 May 23
3
ez-where headscratch
Hi there,
I''m puzzled by this apparently simple query I can''t manage to reassemble
using ez_where plugin.
cond = Caboose::EZ::Condition.new :my_table do
start_on < Time.now
any {end_on > Time.now; end_on.nil?}
end
I keep getting the following result :
>> cond.to_sql
=> ["my_table.start_on < ? AND (my_table.end_on > ?)", Tue May 23
2008 Nov 11
1
Every other week recurring event
I have the code for computing a weekly event:
(start_date..end_date).select{|d| d.wday == wday}
but I am wondering if anyone has any ideas for using this to figure
out a recurring event for every other week. Is it possible to somehow
specify every other within the .select method? Any other
implementation ideas?
--~--~---------~--~----~------------~-------~--~----~
You received this message
2013 Jan 29
2
Count entries in postgresql grouped by date
Hi!
I have a table with visits with a visited_at: attribute which is a datetime
field. They seem to be stored as UTC. Now I want to count all visits each
day and return something like:
{
2013-01-01: 8,
2013-01-02: 4,
2013-01-07: 9,
...
}
So, I did it like this which kind of works...:
def self.total_grouped_by_day(start_date, end_date)
visits = where(visited_at:
2010 Jun 08
2
type conversion with apply or not
Folks, i thought it should be straightforward but after a few hours poking around, I decided it's best to post my question on this list.
I have a data frame consisting of a (large) number of date columns, which are read in from a csv file as character string. I want to convert them to Date type. Following is an example, where the first column is of integer type, while the rest are type
2008 Jun 24
10
Question on passing arguments inside a view.
I''m running into an issue undefined local variable or method
`directoryid'' for #<EditorialsController:0x23f1bf8>
I have two Models on a legacy database and only one controller called
editorials with two actions index and display.
I''m trying to pass in a parameter from the results of my search and
getting the above error.
Example:
two tables one is editorial the
2004 Nov 08
2
Matrix Indexing
Hi,
I have the following problem.
In a csv file I have under column A, the date, and column B, the prices.
Thus, for example, the file looks something like this ->
1/31/04 2.5
2/1/04 2.6
...
4/12/04 3.5
Basically, I use the function inputframe = read.csv( )
which reads the csv file into the inputframe.
My question is, how can I make a function that has, as inputs,
2006 Jun 18
4
uninitialized constant Datetime
I am building an application and I have generated the scaffold for a
product.
In the list method I include something like
my_date = Datetime.now
and the result I get from the webrick is an error
uninitialized constant Datetime
Do I have to add a line with a require?
I am new at ruby on rails
thanks in advance
--
Posted via http://www.ruby-forum.com/.
2024 Oct 30
2
Extracting wind direction and wind speed from wind rose plot
Dear all;
I am searching for a way to extract wind direction and speed from a wind
rose plot. I have a graph and I want to make a dataframe of 5 years with
hourly intervals.
> start_date <- as.POSIXct("2019-01-01 00:00:00")
> end_date <- as.POSIXct("2023-12-31 23:00:00")
> time_sequence <- seq(from = start_date, to = end_date, by = "hour")
> df
2007 Jul 08
2
datetime_select, is creating an instance of the Time class
Hello
It seems that datetime_select, is creating an instance of the Time
class. Why would that be?
I found this while building a site where people can create vigils
(prayer vigils, peace vigils, etc). When I added a validation method
that compared start_date to created_at, it generated the error:
ArgumentError (comparison of Time with DateTime failed):
I was able to put a breakpoint in the
2013 Feb 26
4
3 models, joining and nested queries
I have 3 models,
class Host
ref: string
address: string,
name: string
primary_key=''ref''
has_many :rooms, :class_name=>"Room", :foreign_key=>''host_ref''
Class Room
ref :string
host_ref: string
capacity: integer
primary_key=''ref''
has_many
2006 Mar 04
5
has_many and belongs_to example?
Hi!
If i have 2 tables i.e. product and images and product has_many images,
image belongs_to product - how to create _form.rhtml, new/create and
edit/update methods in product controller, so in a single form i can add
one product and MANY (let''s assume for now that this number is fixed)
images for this product?
Pleeeeease help me :)
--
Posted via http://www.ruby-forum.com/.
2024 Oct 30
1
Extracting wind direction and wind speed from wind rose plot
A wind rose plot omits time information. Your request is simply not possible.
On October 30, 2024 3:48:03 AM PDT, javad bayat <j.bayat194 at gmail.com> wrote:
>Dear all;
>I am searching for a way to extract wind direction and speed from a wind
>rose plot. I have a graph and I want to make a dataframe of 5 years with
>hourly intervals.
>
>> start_date <-
2011 Aug 26
2
how to convert Date to this json format
Hi
I have to create a json date like
{"startDate":"\/Date(1291145744713-0700)\/","endDate":"\/Date(1293824144713-0700)\/"}
This is just an example.
My case startdate = Time.now-2.day
enddate = Time.now
I dont know how to convert this to the above format. Please help
Thanks
--
Posted via http://www.ruby-forum.com/.
--
You
2009 Jun 07
17
ActiveRecord Classes
I''m having a little trouble with understanding how to work out the
schematic for some of my classes using ActiveRecord when a file is in my
lib directory:
Brief example:
Here''s the outline of the files in use:
....app
........controllers
............application_controller.rb
............rushing_offenses_controller.rb
........models
............rushing_offense.rb
....lib
2010 Oct 13
10
Rails 2.3.8 - What happens to a datetime field between a form being submitted and the controller receiving the params
I currently have a model that simply contains one datetime field:
class CreateElectricityReadings < ActiveRecord::Migration
def self.up
create_table :clocks do |t|
t.datetime :time_keeper
t.timestamps
end
end
def self.down
drop_table :clocks
end
end
If I enter the date string "13/10/2010" into this field its showing up
in the controller as
2007 May 01
5
duplicate key violates unique constraint
I''ve run into an interesting issue. When setting up a table with data
from a file (I''m doing this in a block). I find that I can''t create
separate entries manually after the import. It complains about a
duplicate primary key. I''ve tried Schedule.id += 1 but id= either
isn''t defined or accessible in the class
Here is my code:
2007 Apr 09
1
help with ActiveRecord joins
I''m working on a fairly complex join query and could use a bit of advice
from more expert users of ActiveRecord.
I have an events table with quite a lot of data, with has_many relations
to categories, age_groups, and event_images. In my first naive
implementation, each event had a date, so to load all upcoming events
efficiently, I''d do:
Event.find(:all,
2013 Mar 25
1
validates presence of foreign key fails in nested form
I''m using accepts_nested_attributes as follows:
class Timesheet < ActiveRecord::Base
attr_accessible :status, :user_id, :start_date, :end_date,
:activities_attributes
has_many :activities, dependent: :destroy
has_many :time_entries, through: :activities
accepts_nested_attributes_for :activities, allow_destroy: true
end
class Activity < ActiveRecord::Base
attr_accessible
2006 Feb 24
2
Model Inheritance?
Hello,
I need some help with designing a model I have in mind. I''m not sure
what the best way to do it in Ruby/Rails is, or even if what I''m
thinking is possible.
Basically, I have a system where I want to treat everything as a
"message." A Message is a basic model object with a title and
message_text. It can stand on it''s own, or it can be
2012 Apr 14
7
undefined method `model_name' for NilClass:Class
Hi guys,
I just started using Ruby on Rails. After implementing the RoR blog
tutorial I started with my own data model.
Sadly I am not able to get my create page running.
Model:
class Activity < ActiveRecord::Base
validates :activity, :presence => true
validates :forKids, :presence => true
validates :start_date, :presence => true
end
Controller:
class ActivitiesController <