hi.. i m using date picker like below <%= calendar_date_select_tag "e_date[]", Date.today, :popup => :force ,:time => true %> when i submit the form i get parameter like below September 30, 2009 03:08 PM i want to cut the time from it... tat is 03:08 PM and September 30, 2009 has to be separated.. any helps for this... Thanks for taking time to help -- Posted via http://www.ruby-forum.com/.
just remove :time option from the syntax.. -- Posted via http://www.ruby-forum.com/.
Brijesh Shah wrote:> just remove :time option from the syntax..thanks for the reply... actually i need time and date aswell . but i want to split the date and time .. how can i do it September 30, 2009 03:08 PM -- Posted via http://www.ruby-forum.com/.
You can separate date and time by... first you need to convert into date format datetime=params[:e_date] datetime=datetime.to_date date = date.strftime(''%Y-%m-%d'')" I hope this helps u... -- Posted via http://www.ruby-forum.com/.
Hi Newb newb use @date.strftime("%B %d, %Y") to display only date no time. and in table insert September 30, 2009 03:08 PM Newb Newb wrote:> Brijesh Shah wrote: >> just remove :time option from the syntax.. > > thanks for the reply... > actually i need time and date aswell . > but i want to split the date and time .. > how can i do it > > September 30, 2009 03:08 PM-- Posted via http://www.ruby-forum.com/.
2009/9/30 Brijesh Shah <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > You can separate date and time by... > > first you need to convert into date format > datetime=params[:e_date] > datetime=datetime.to_dateI think there is no need to convert it to a Date, just use strftime on the DateTime object to show just the date portion. Colin> date = date.strftime(''%Y-%m-%d'')" > > I hope this helps u... > -- > Posted via http://www.ruby-forum.com/. > > > >
Hi Colin Conversion is required because passing value is string not datetime ... -- Posted via http://www.ruby-forum.com/.
Brijesh Shah wrote:> Hi Colin > > Conversion is required because passing value is string not datetime ...thank you guys... and thanks to Brijesh Shah.. it works now -- Posted via http://www.ruby-forum.com/.
2009/9/30 Brijesh Shah <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > Hi Colin > > Conversion is required because passing value is string not datetime ... >Yes you are right, I was thinking datetime_select was being used to read into a DateTime object. Colin
Colin Law wrote:> 2009/9/30 Brijesh Shah <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>: >> >> Hi Colin >> >> Conversion is required because passing value is string not datetime ... >> > > Yes you are right, I was thinking datetime_select was being used to > read into a DateTime object. > > Colinhi all.. i want to ask one more help... d0_time = d0.strftime("%I:%M %p") d1_time = d1.strftime("%I:%M %p") 12:00 am 07:00 pm i get two times here.i ll take the above times as from and to. i have time as field into my table.it stores like 01:17:56 am. i want to fetch the records which is between the above two times .. how can i implement the query pls suggest me -- Posted via http://www.ruby-forum.com/.
Use TIME_FORMAT in mysql query to fetch records.. SELECT * FROM TABLE_NAME WHERE TIME_FORMAT( time, "%h:%i %p" ) > "12:00 am" AND TIME_FORMAT( time, "%h:%i %p" ) < "7:00 pm" Set the format as per your requirement... http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_time-format -- Posted via http://www.ruby-forum.com/.
Newb Newb wrote: [...]> hi all.. > i want to ask one more help... > > d0_time = d0.strftime("%I:%M %p") > d1_time = d1.strftime("%I:%M %p") > > 12:00 am > 07:00 pm > i get two times here.i ll take the above times as from and to. > i have time as field into my table.it stores like 01:17:56 am.Are you storing the time as a string in the DB? If so, don''t. Store times as time or datetime.> > > i want to fetch the records which is between the above two times .. > how can i implement the querySELECT * FROM table WHERE hour(time) BETWEEN 0 and 19> > pls suggest meBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
Marnen Laibow-Koser wrote:> Newb Newb wrote: > [...] >> hi all.. >> i want to ask one more help... >> >> d0_time = d0.strftime("%I:%M %p") >> d1_time = d1.strftime("%I:%M %p") >> >> 12:00 am >> 07:00 pm >> i get two times here.i ll take the above times as from and to. >> i have time as field into my table.it stores like 01:17:56 am. > > Are you storing the time as a string in the DB? If so, don''t. Store > times as time or datetime. > >> >> >> i want to fetch the records which is between the above two times .. >> how can i implement the query > > SELECT * FROM table > WHERE hour(time) BETWEEN 0 and 19 >> >> pls suggest me > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.orghi.. i m using date picker like below <%= calendar_date_select_tag "e_date[]", Date.today, :popup => :force ,:time => true %> is it possible to disable the dates ... i want to able to select only time... is it possible... thanks in advance -- Posted via http://www.ruby-forum.com/.
Model.find(:all, :conditions => {:time_field => (from..to)}) On Sep 30, 7:02 am, Newb Newb <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Colin Law wrote: > > 2009/9/30 Brijesh Shah <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>: > > >> Hi Colin > > >> Conversion is required because passing value is string not datetime ... > > > Yes you are right, I was thinking datetime_select was being used to > > read into a DateTime object. > > > Colin > > hi all.. > i want to ask one more help... > > d0_time = d0.strftime("%I:%M %p") > d1_time = d1.strftime("%I:%M %p") > > 12:00 am > 07:00 pm > i get two times here.i ll take the above times as from and to. > i have time as field into my table.it stores like 01:17:56 am. > > i want to fetch the records which is between the above two times .. > how can i implement the query > > pls suggest me > -- > Posted viahttp://www.ruby-forum.com/.