Re: date formats in select statements

[prev] [thread] [next] [Date index for 2004/11/23]

From: Peter Speltz
Subject: Re: date formats in select statements
Date: 16:54 on 23 Nov 2004
--- Isarin.Sathitruangsak@xxxx.xxx wrote:

> 
> Sorry I should have mentioned it in my question.  I did look at the page
> but I can't get to work.  I am still missing something.
> 

I haven't actually played with it doing that yet.

> With the code as followed, I've got this error:
> Can't locate object method "hms" via package "Nov  2 2004 12:39PM" (perhaps
> you forgot to load "Nov  2 2004 12:39PM"?) at tstcdbi line 38.
> 

This error i believe is from calling the method on a object that was
stringified first. Do you know what i'm talking about? IF not see
columns("Stringify") or sub stringify_self in docs. CDBI objects stringify
themselves automatically if used in string context and that's what's happening
to your date object before you try to call "hms" . Track down the call causing
the error and make that object not stringify. 

> 
> ======================================
> my $xmit = Feed::Xmit->new();
> my $null = 'is null';
> my @xmits = $xmit->search_where(
>                 feed_id      => $feedId,
>                 start_time   => [ { 'between', [ $fromdate, "$todate
> 23:59:59" ]}, \$null ],

the $todate gets stringified above since it's in quotes. From date shouldn't.

>                 end_time     => [ { 'between', [ $fromdate, "$todate
> 23:59:59" ]}, \$null ],
> );
> 
> foreach my $x (@xmits) {
>         print $x->trans_id . ",";
>         print $x->start_time->hms if defined $x->start_time;
>         print ",";
>         print $x->end_time->hms if defined $x->end_time;
>         print ",";
>         my $rel = Feed::GDB->retrieve( trans_id => $x->trans_id, load_type
> => 'rel' );
>         print $rel->end_time if $rel;
> }
> 
> ===========================
> package Feed::Xmit;
> use base 'Feed::DBI';
> use Class::DBI::AbstractSearch;
> 
> Feed::Xmit->table('trans_master');
> Feed::Xmit->columns(Primary => qw/trans_id/);
> Feed::Xmit->columns(Essential => qw/trans_id feed_id start_time end_time/);
> Feed::Xmit->columns(Temp => qw/ccyymmdd start_hour end_hour/);
> 
> Feed::Xmit->has_a(start_time => 'Class::Date',
>                   inflate => 'new',
>                   deflate => 'string',                  );
> Feed::Xmit->has_a(end_time => 'Class::Date',
>                  inflate => 'new',
>                  deflate => 'string',                  );
> 
> 
> 
> 
>                                                                              
>                                                          
>                       Peter Speltz                                           
>                                                          
>                       <peterspeltz@yaho        To:       class dbi list
> <cdbi-talk@xxxxxx.xxxxx.xxx>                                   
>                       o.com>                   cc:                           
>                                                          
>                                                Subject:  Re: date formats in
> select statements                                         
>                       11/23/2004 11:13                                       
>                                                          
>                       AM                                                     
>                                                          
>                                                                              
>                                                          
>                                                                              
>                                                          
> 
> 
> 
> 
> 
> --- Isarin.Sathitruangsak@xxxx.xxx wrote:
> 
> > Hi,
> >
> > could someone please help me shed some light on how to convert date
> format
> > in CDBI, not using set_sql?
> > I am not really sure how to use Class::Date or DateTime with  CDBI.
> Sorry
> > I don't follow what the docs say about it.
> 
> Did you check out the class-dbi cookbook article on this?
> http://www.class-dbi.com/cgi-bin/wiki/index.cgi?ClassDate
> 
> =====
> pjs
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> 
> 
> 
> 
> 
> 


=====
pjs

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

date formats in select statements
Isarin.Sathitruangsak 16:01 on 23 Nov 2004

Re: date formats in select statements
Peter Speltz 16:13 on 23 Nov 2004

Re: date formats in select statements
Peter Speltz 16:54 on 23 Nov 2004

Generated at 11:35 on 01 Dec 2004 by mariachi v0.52