similar to: calculating the difference between days?

Displaying 20 results from an estimated 200 matches similar to: "calculating the difference between days?"

2006 Dec 11
1
Compute date during before_validation_on_create
Hello, - the form posted by the user have a date field - this date is begin_date, I need to compute end_date - so, added callback before_validation_on_create - in this method I do : end_date = begin_date >> 12 - unfortunately, beeing in before_validation the actual self.begin_date have not been type casted - It''s always a string - unfortunately again, I can''t put this code
2008 Oct 14
4
replace_html not working
hallo, everyone can anybody help me? i did add my code under ENGINES as a module in a project. before the change , all worked . and the differenz between both is only about application''s environment, before is Ruby version 1.8.6 (i486-linux) RubyGems version 1.1.1 Rails version 2.0.2 Active Record version 2.0.2 Action Pack version 2.0.2
2006 Apr 18
3
ez_where query question
I''m having fun composing queries with ez_where, but am stuck on how to formulate the following using the ez syntax: (begin_date >= ? OR end_date >= ?) AND (description LIKE ? OR name LIKE ?) There are two clauses, each containing OR operators (the ez ''any'' syntax) but both clauses must evaulate to true for a match. Can anyone suggest the proper way to construct
2006 Feb 09
17
complicated finds are eating my sole
I abandoned ruby way for find_by_sql and still can''t get this... @myplacement = Placement.find_by_sql( "select * from placement where :intake_date >= beg_intake_date and :intake_date <= end_intake_date") just a simple date range...it''s killing me - If I knew how to load placement controller into irb, I could probably try out finds interactive mode... Thanks
2006 Feb 28
6
Activerecord equivalent of the SQL "SUM()" function.
Search doesn''t seem to be working, so forgive me if I''m covering old ground here, but I''m having a difficult time figuring out how to implement a "SUM()" function using Active record. Obviously, I could just create a query, but I''d rather make it part of my active record object. Basically I have an object called "Report <
2006 Jan 16
1
Bundled resource -- something I''m missing
I have a decoupled form embedded in my pages ? a search box that has date fields ? and of course the search fields are not in my model. However, picking dates is a great use for the Dynarch calendar. It seems that by using the syntax: <%= render :partial => ?filter_box? %> In my view and... <%= dynarch_date_select ''filter_box'', ''begin_date'' %>
2006 Jan 17
4
find_by_sql column ordering defect?
Hello. I have a program that accesses a metadata (translation) table for column names as well as the ordering of columns for a specific model. Also in there is a collection of bool options such as column_visible_on_form, column_visible_on_screen_quicklist etc. The idea is that our customer can specify to a certain extent how their layout/user interface will appear. To accomplish this, I use
2006 Jun 14
4
Using now() to determine what should be displayed
I''m trying to create a paginated list that will take note of the "end_date" field in my table. This is what I have: @post_pages, @posts = paginate(:posts, :per_page => 10, :order_by => ''end_date'') in the controller. And for the view: <h1>Posts ending soon</h1> <ul><% for post in @posts do %> <strong>Post Title:
2006 Jun 25
1
Sorting ferret results by column
I have the acts_as_ferret plugin installed. Everything searches great, but I would like to limit the results (i.e. by ''end_date'') and sort them (by ''end_date''). ''end_date'' is a valid column in my "posts" table. Here''s the code I have already: @posts = Post.find_by_contents(params[:query]) params[:query] comes from a form. I
2009 Aug 13
2
need technique for speeding up R dataframe individual element insertion (no deletion though)
Hi fellas, I am working on a dataframe cam and it involves comparison within the 2 columns - t1 and t2 on about 20K rows and 14 columns. ### cap = cam; # this doesn't take long. ~1 secs. for( i in 1:length(cam$end_date)) { x1=strptime(cam$end_date[i], "%d/%m/%Y"); x2=strptime(cam$end_date[i+1], "%d/%m/%Y"); t1= cam$vol[i]; t2= cam$vol[i+1];
2006 Dec 08
2
trouble using ActiveRecord classes
I''ve been trying unsuccessfully for the better part of today to write a worker that can use by ActiveRecord model classes. The bizarre thing is that worker just stops at the point accessing the database connection. An exception isn''t raising, it just dies. My worker class is below, I''ve interspersed log messages throughout to try to determine where it is dying. =====
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/.
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 Mar 31
0
Date format in Rails 3.0 using sqlite3
Hi, I am new to Ruby and Rails, so I don''t know if this is my fault, but maybe this is a bug in Rails (I''m using Rails 3.0 beta) which should be reported. I have following search statement: [code]events = CalendarEvent.find :all, :conditions => { :target_date => begin_date..end_date }[/code] which produces following sqlite output: [code]SELECT
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
2011 May 19
1
update_attributes updates data from second instance of nested form but not the first
Got a weird situation with an update put to a controller with a form with nested attributes. On the data below, I am updating data for both items (''0'' and ''1'') in rosters_attributes (in the example below I am updating the ''name'' attribute to a new value in both cases. What I am stuck on is that ''1'' gets its data updated,
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 25
1
Using AND in :conditions queries
I have what amounts to a simple search engine running through a table using input from a form. Everything works fine when looking for "title" or "body" But, when I want to couple that with an AND statement the search still works fine, but it seems to disregard the AND statements. Code below: In the view: <%= start_form_tag :action=> "show_search" %>
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