search for: to_date

Displaying 20 results from an estimated 52 matches for "to_date".

2009 Feb 04
4
Rails 2.2.2 to_date and to_datetime methods
In the console I see this behaviour: >> "19270412000000".to_date.methods => ["ns?", "mon", "ago", "end_of_month", "months_since", "default_inspect", "minus_without_duration", ... >> "19270412000000".to_date.class => Date >> "19270412000000".class => Str...
2007 Nov 02
3
Date Issues + Oracle + RoR
Hi Experts I''ve a product like this ID -> 1 Name -> Xyz Price -> 30 Created_at -> 02-NOV-07 from_date = Date.new(2, 10, 07) to_date = Date.new(2, 10, 07) @product = Product.find_by_sql("select * from products where created_at between from_date and to_date") code works perfectly, buy my issue is i dont get any data. always says no record found but if i use as like this from_date = Date.new(2, 10, 07) to_date = Date...
2011 Feb 04
5
Date parse - month and day reversed
I am getting the month and day reversed in parsing a date. I am wondering if there is some intelligence in Ruby that knows that at the moment I am in Mexico, as the parsing is working as if I was "6/15/2008".to_date => ArgumentError: invalid date "15/6/2008".to_date => Sun, 15 Jun 2008 What I really want is my date to be understood as month/day/year. Is there a way to tell Ruby or Rails to do this? Been poking around on google and do not see an answer that works here. I found a page with th...
2009 Dec 30
9
Oracle adapter problem? How to fix this?
Hi, My setup is: Ruby 1.8.6 Rails 2.3.5 activerecord-oracle-adapter (1.0.0.9250) I upgraded Rails and the adapter recently and I just went through hell trying to find a problem while inserting a record in a table. Rails was giving me this error: OCIError (ORA-02289: sequence does not exist): stmt.c:539:in oci8lib.so c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:753:in `exec''
2006 Apr 25
1
Array of dates/times from time.now till nextweek
Hi, I would like to make @dates in my controller. I tried the following: startdate = Time.now enddate = startdate.next_week for enddate > startdate @dates << startdate startdate = startdate.tomorrow end But I get an errormessage when I check the syntax: "warning: useless use of a variable in void context" Anyone? Thanks! Steven. -- Posted via
2007 Dec 12
6
Add a month to a Date object
Howdy all, This may be the dumbest question in the world, but how can you "add one month" to a Date object? I can''t just add 30 days, because months have varying lengths. Any help would be much appreciated... Thanks! -Neal --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2009 Feb 22
6
CHECK if param exists? please help
hi folks. i want to check if a param exists if not to set it to a default value for my date range filter. in my controller i have: @from_date = Date.strptime(params[:startdate],"%d/%m/%Y") @to_date = Date.strptime(params[:enddate],"%d/%m/%Y") @articles = @results.find(:all, :conditions => [ "created_at >= ? and created_at <=?",@from_date,@to_date], :order => ''created_at desc'', :page...
2008 Jun 08
20
how to parse a "dd/mm/yyyy" formatted date string???
Hi, I''m stuck. How do you parse a "dd/mm/yyyy" formatted date string??? I get a date format error. Thanks in advance Greg --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to
2006 Jun 13
17
reconstituting a date
...out][:time_in] elsif params[:user][:in_out] == "Out" @in_out.time_out = params[:in_out][:time_in] params[:in_out][:time_in] = nil end but since it really isn''t a date time, only a null gets saved. How do I reconstitute it as a date because @in_out.time_in.to_date = params[:in_out][:time_in] generates an error and doesn''t work. Craig
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
2008 Apr 22
2
How to convert time from rss feed to another format ?
...I need to parse the rss feed and use the pubDate field to generate a field in a xml file to use as an input to simile timeline. RSS returns the pubDate as : Sun Feb 24 06:33:32 UTC 2008 But I need it as a string : "Feb 24 2008 06:33:32 PST" When I do : ... @dt=feed_item.time @dt=@dt.to_date word_date=''%b %d %Y %H:%M:%S %z'' puts @dt.strftime(word_date) ... Then I am getting : Feb 24 2008 00:00:00 +0000 what am I doing wrong? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you ar...
2009 Dec 14
1
AGI with PHP
...> 111,n,HangUp() My php file is: #!/usr/bin/php <?php $start = '5'; $mysql_host = 'localhost'; $mysql_user = 'username'; $mysql_password = 'password'; $my_database = 'asteriskcdr'; $dbtable = 'cdr'; $from_date = '20091205000000'; $to_date = '20100104235959'; $callnum = '0'; $minutes = '0'; $query_duration = "SELECT SUM(billsec) FROM $dbtable WHERE calldate >= $from_date AND calldate <= $to_date AND disposition='ANSWERED' AND dst like '04%'"; $query_calls = "SELECT COUNT(...
2008 Jun 28
14
Date Field convert to Seconds since Epoch
Hi, I was wandering if anyone could help me with this problem: Right now I am using a field in my database which is of type ''Date'' (in the form dd-mm-yyyy). I would like to convert this value (for example 26-06-08) into a number of seconds since epoch or into another form so I can compare it with todays date (from Date.now) so that I can tell the difference between the two dates
2006 Mar 01
3
Convert Date to Time
Hi, How do i convert a Date to a Time?? I have a date returned from sql and i need to be able to use handy functions like next_week or beggining of week. Any help appreciated Thanks, Chris -- Posted via http://www.ruby-forum.com/.
2006 Feb 12
3
Timestamp -> Date
I have a timestamp in a row in my MySQL DB, and I can output the timestamp, but what method could I use to turn the timestamp into the date, like the PHP function date()? Also, can I have the link to any place that lists all RoR Methods/Classes that is not the official one? If no other ones exist, no problem :) -- Posted via http://www.ruby-forum.com/.
2013 Jan 29
2
Count entries in postgresql grouped by date
...end_date) visits = where(visited_at: start_date..end_date) visits = visits.group("date(visited_at)") visits = visits.select("date(visited_at) as date, count(visits.id) as total_visits") visits = visits.order("date ASC") visits.group_by { |v| v.date.to_date } end It doesn''t return exactly the format I want but that''s not the big problem. The problem is that if a visit happens near midnight it may be counted at the "wrong" date due to time zones. I understand why, because "date(visited_at)" doesn''t k...
2006 Jul 06
6
Help with overriding / overwriting date values in ActiveRecord to accept Euro Style Date from a Textbox
...example from RDoc... i tried to overwrite/overload/override the = function to write in the date.. Cant get it to work because .. i dont knoe what format should it accept.. i''ve tried hardcoding things like below but it all doesnt work.. i) "2006-01-23" i) "2006-01-23".to_date i) Time.now Any ideas anyone? Eg code def install_date=(newdate) write_attribute(:install_date, "2006-01-23") end John W
2006 Jan 22
8
Date Calculation
I am trying to calculate the number of days between 2 dates using Time.now - object.date where object.date is a date pulled from a database. I want to display the age of the entry in the database in days. I keep getting an error about not being able to convert a date into a float. What am I doing wrong. If I use object.date - object.date it seems to work but the answer is useless (0). I
2009 Sep 14
9
ActiveRecord::StatementInvalid (invalid date) with Oracle
Hello all. I am a novice Ruby on Rails programmer, starting my first project using a legacy Oracle 10 database. Using ''reverse_scaffold'' I have created the models/controllers/views for my existing Oracle tables. All seems to work well, using /model/index, /model/show for most of my tables, *except* when one of the tables contains a Oracle ''date'' column, for
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 <