Quoting Simon Law <[EMAIL PROTECTED]>:

> 
> CREATE TABLE tablename (field INTERVAL);
> INSERT INTO tablename VALUES('3 weeks');
> SELECT field FROM tablename;

> |   21 days |
> 
> The output   shows up in days or months but not weeks how do i make 
Internally, INTERVAL is stored as a 12byte tuple (years, months, days,
hours, minutes, seconds, microseconds). It discards any knowledge of
"weeks" (and "centuries" likewise) when it encodes the interval. So
there's no way to force it to say "weeks" back to you. There is no
datestyle that will do it for you, either.

You can MANUALLY extract the number of days in the interval, and divide
by 7 (round up or down, your choice).

SELECT EXTRACT(DAYS FROM INTERVAL '3 WEEKS')

Note, however, that if you define an interval with units greater than
days (i.e. months or years) you'll get nothing, which is reasonable:
months and years do not have fixed numbers of weeks in them.




---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [EMAIL PROTECTED] so that your
       message can get through to the mailing list cleanly

Reply via email to