RE: date question

2004-10-12 Thread Carter Thompson

Lori,

I'm not that familar with Postgresql, however you should check out
the online documentation on SQL Functions and roll your own.  Here's
the link to the page.

http://www.postgresql.org/docs/aw_pgsql_book/node164.html

Several of the examples appear to be close to what I think you're
looking for in a function.

Cheers,

Carter.


 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of Lori
 Sent: Tuesday, October 12, 2004 2:29 PM
 To: [EMAIL PROTECTED]
 Subject: date question
 
 
 This is a postgresql question , slam me if you must, but this is the 
 only list where I get a
 fast response and I know many of you use postgresql 
 
 I have a int field called when_month and I want to use it to get the 
 full month name
 something like :
  update  mytable set myfield = date_part(month,'1/5/2004');
  the problem is date part returns 5 not May
 
  If I wanted to do this in a program I could easily do it with an 
 array ,but cant find quick way to do in postgresql ?
 
 I have looked it up on the postgresql site and on google but 
 cant find a 
 simple function that will do the trick
 
 
 ___
 Perl-Win32-Users mailing list 
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: date question

2004-10-12 Thread Charles K. Clarkson
Lori [EMAIL PROTECTED] wrote:

: This is a postgresql question , slam me if you must, but
: this is the only list where I get a fast response and I
: know many of you use postgresql  
: 
: I have a int field called when_month and I want to use
: it to get the full month name something like :
: update  mytable set myfield = date_part(month,'1/5/2004');
: the problem is date part returns 5 not May
: 
:  If I wanted to do this in a program I could easily
: do it with an array ,but cant find quick way to do in
: postgresql ?
: 
: I have looked it up on the postgresql site and on google
: but cant find a simple function that will do the trick

I think you want the to_char or the to_timestamp
function. (Read the note.)

http://www.postgresql.org/docs/7/interactive/functions2976.htm



HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: date question

2004-10-12 Thread Lori
Charles K. Clarkson wrote:
Lori [EMAIL PROTECTED] wrote:
: This is a postgresql question , slam me if you must, but
: this is the only list where I get a fast response and I
: know many of you use postgresql  
: 
: I have a int field called when_month and I want to use
: it to get the full month name something like :
: update  mytable set myfield = date_part(month,'1/5/2004');
: the problem is date part returns 5 not May
: 
:  If I wanted to do this in a program I could easily
: do it with an array ,but cant find quick way to do in
: postgresql ?
: 
: I have looked it up on the postgresql site and on google
: but cant find a simple function that will do the trick

   I think you want the to_char or the to_timestamp
function. (Read the note.)
http://www.postgresql.org/docs/7/interactive/functions2976.htm

HTH,
Charles K. Clarkson
 

thanks charles, I have been playing with those 2 functions for the last 
hour or so, i
this comes close to what I want
update mytable set myfield=to_char(current_timestamp,'MON');

the result is myfield is set to OCT which is what I want but when I try 
to use a variable
update mytable set myfield=to_char('20040505','MON');
get error:
update mytable set myfield=to_date(when_month,'MON');
update mytable set myfield=to_char('05','MON');
as well as
update mytable set full_month= to_date('01/'05'/2004','DDMON');
all get errors

back to the drawing board
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Date question

2002-05-22 Thread Zeno Lee

It depends on what you mean by following month.  
How do you define the following month after May 31?  Is it June 30?
How do you define the following month after June 30?  Is it July 30? or is
it July 31?
February 28 - March 28? or March 31?  
Do you mean last number of the month, exactly 30 days after, or the same
number as the previous month?

It's all possible to do, you just have to know what you mean by following
month.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 21, 2002 3:57 PM
To: [EMAIL PROTECTED]
Subject: Date question


I have a question about my date snippet.

my ($mday, $mon, $year) = (localtime(time))[3..5];
my $pagedate = sprintf %02u/%02u/%u, $mon + 1, $mday,
 $year + 1900;

The above will print out the date like 05/21/2002 

How can I create the date exactically to the same day but
 to the following month?

Then I would have: start date 05/21/2002
   end date   06/21/2002

Or for whatever date
Thanks in advance.
Allan
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Date question

2002-05-22 Thread Capacio, Paula J

I
use Date::Calc;

although there are lots of Date modules available.  
paula
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
Stephen J Martin
Sent: Wednesday, May 22, 2002 7:54 AM
To: [EMAIL PROTECTED]
Cc: Carl Jolley
Subject: Re: Date question


On Tue, 21 May 2002 22:11:53  
 Carl Jolley wrote:
This is a difficult question but I'll try to answer.
snip
OR if you wanted to correctly wrap from December to January of the
following year;

my ($mday, $mon, $year) = (localtime(time))[3..5];
$mon+=1;
$year+=1900;
my $startdate = sprintf %02u/%02u/%u, $mon, $mday, $year;
if(++$mon==13) {
  $mon=1;
  $year++;
}
my $lastdate = sprintf %02u/%02u/%u, $mon, $mday, $year+1900;

snip

On Tue, 21 May 2002 [EMAIL PROTECTED] wrote:

 I have a question about my date snippet.
snip

It's more difficult even than that, e.g. on 31st May the code above will give 31st 
June, which is invalid. In fact, on my machine today it gives 06/22/3902, so adding 
1900 to the year was not necessary.

I could have a go at this, but surely it's been done before?

By the way, what should you do with short months? Always advance by 31 days or just 
collapse several days to the last day of the month? Do banks/ accountants/ the law 
have a strict definition of one month from today that works in all cases? Is it 
different in the US/ UK/ Europe/ elsewhere?
---
Steve Martin
[EMAIL PROTECTED]





Outgrown your current e-mail service?
Get a 25MB Inbox, POP3 Access, No Ads and No Taglines with LYCOS MAIL PLUS.
http://login.mail.lycos.com/brandPage.shtml?pageId=plus
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs