- new to_char(interval, text)
- new millisecond (ms) and microsecond (us) support - more robus parsing from string - used is separator checking for non-exact formats like to_date('2001-9-1', 'YYYY-MM-DD') - SGML docs are included Karel Zak
This commit is contained in:
parent
74dde13e2c
commit
2a34134b6c
@ -1,4 +1,4 @@
|
||||
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.68 2001/08/31 07:45:09 ishii Exp $ -->
|
||||
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.69 2001/09/06 03:22:41 momjian Exp $ -->
|
||||
|
||||
<chapter id="functions">
|
||||
<title>Functions and Operators</title>
|
||||
@ -1564,6 +1564,12 @@
|
||||
<entry>convert timestamp to string</entry>
|
||||
<entry>to_char(timestamp 'now','HH12:MI:SS')</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>to_char(interval, text)</entry>
|
||||
<entry>text</entry>
|
||||
<entry>convert interval to string</entry>
|
||||
<entry>to_char(interval '15h 2m 12s','HH24:MI:SS')</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>to_char(int, text)</entry>
|
||||
<entry>text</entry>
|
||||
@ -1645,6 +1651,14 @@
|
||||
<entry>SS</entry>
|
||||
<entry>second (00-59)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>MS</entry>
|
||||
<entry>millisecond (000-999)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>US</entry>
|
||||
<entry>microsecond (000000-999999)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>SSSS</entry>
|
||||
<entry>seconds past midnight (0-86399)</entry>
|
||||
@ -1911,6 +1925,23 @@
|
||||
<literal>to_date('20000Nov31', 'YYYYMonDD')</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Millisecond <literal>MS</literal> and microcesond <literal>US</literal>
|
||||
values are in conversion from string to timestamp used as part of
|
||||
second after decimal point. For example
|
||||
<literal>to_timestamp('12:3', 'SS:MS')</literal> is not 3 milliseconds,
|
||||
but 300, because the conversion count it as <literal>12 + 0.3</literal>.
|
||||
It means for format 'SS:MS' is '12:3' or '12:30' or '12:300' same
|
||||
number of miliceconds. For the three milliseconds must be used
|
||||
'12:003' that the counversion count as
|
||||
<literal> 12 + 0.003 = 12.003 seconds </literal>. Here is a more
|
||||
complex example:
|
||||
<literal>to_timestamp('15:12:02.020.001230','HH:MI:SS.MS.US')</literal>
|
||||
is 15 hours, 12 minutes, 2.021230 seconds.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.49 2001/05/03 22:53:07 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.50 2001/09/06 03:22:42 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -33,9 +33,6 @@ static double time2t(const int hour, const int min, const double sec);
|
||||
static int EncodeSpecialTimestamp(Timestamp dt, char *str);
|
||||
static Timestamp dt2local(Timestamp dt, int timezone);
|
||||
static void dt2time(Timestamp dt, int *hour, int *min, double *sec);
|
||||
static int interval2tm(Interval span, struct tm * tm, float8 *fsec);
|
||||
static int tm2interval(struct tm * tm, double fsec, Interval *span);
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* USER I/O ROUTINES *
|
||||
@ -412,7 +409,7 @@ tm2timestamp(struct tm * tm, double fsec, int *tzp, Timestamp *result)
|
||||
/* interval2tm()
|
||||
* Convert a interval data type to a tm structure.
|
||||
*/
|
||||
static int
|
||||
int
|
||||
interval2tm(Interval span, struct tm * tm, float8 *fsec)
|
||||
{
|
||||
double time;
|
||||
@ -444,7 +441,7 @@ interval2tm(Interval span, struct tm * tm, float8 *fsec)
|
||||
return 0;
|
||||
} /* interval2tm() */
|
||||
|
||||
static int
|
||||
int
|
||||
tm2interval(struct tm * tm, double fsec, Interval *span)
|
||||
{
|
||||
span->month = ((tm->tm_year * 12) + tm->tm_mon);
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: pg_proc.h,v 1.207 2001/08/26 16:56:02 tgl Exp $
|
||||
* $Id: pg_proc.h,v 1.208 2001/09/06 03:22:42 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* The script catalog/genbki.sh reads this file and generates .bki
|
||||
@ -2476,10 +2476,12 @@ DATA(insert OID = 1776 ( to_char PGUID 12 f t f t 2 f 25 "701 25" 100 0 0 100
|
||||
DESCR("format float8 to text");
|
||||
DATA(insert OID = 1777 ( to_number PGUID 12 f t f t 2 f 1700 "25 25" 100 0 0 100 numeric_to_number - ));
|
||||
DESCR("convert text to numeric");
|
||||
DATA(insert OID = 1778 ( to_timestamp PGUID 12 f t f t 2 f 1184 "25 25" 100 0 0 100 to_timestamp - ));
|
||||
DATA(insert OID = 1778 ( to_timestamp PGUID 12 f t f t 2 f 1184 "25 25" 100 0 0 100 to_timestamp - ));
|
||||
DESCR("convert text to timestamp");
|
||||
DATA(insert OID = 1780 ( to_date PGUID 12 f t f t 2 f 1082 "25 25" 100 0 0 100 to_date - ));
|
||||
DESCR("convert text to date");
|
||||
DATA(insert OID = 1768 ( to_char PGUID 12 f t f t 2 f 25 "1186 25" 100 0 0 100 interval_to_char - ));
|
||||
DESCR("format interval to text");
|
||||
|
||||
DATA(insert OID = 1282 ( quote_ident PGUID 12 f t t t 1 f 25 "25" 100 0 0 100 quote_ident - ));
|
||||
DESCR("quote an identifier for usage in a querystring");
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* formatting.h
|
||||
*
|
||||
* $Id: formatting.h,v 1.7 2001/01/24 19:43:28 momjian Exp $
|
||||
* $Id: formatting.h,v 1.8 2001/09/06 03:22:42 momjian Exp $
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
|
||||
@ -10,7 +10,7 @@
|
||||
* The PostgreSQL routines for a DateTime/int/float/numeric formatting,
|
||||
* inspire with Oracle TO_CHAR() / TO_DATE() / TO_NUMBER() routines.
|
||||
*
|
||||
* Karel Zak - Zakkr
|
||||
* Karel Zak
|
||||
*
|
||||
* -----------------------------------------------------------------------
|
||||
*/
|
||||
@ -22,6 +22,7 @@
|
||||
|
||||
|
||||
extern Datum timestamp_to_char(PG_FUNCTION_ARGS);
|
||||
extern Datum interval_to_char(PG_FUNCTION_ARGS);
|
||||
extern Datum to_timestamp(PG_FUNCTION_ARGS);
|
||||
extern Datum to_date(PG_FUNCTION_ARGS);
|
||||
extern Datum numeric_to_number(PG_FUNCTION_ARGS);
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: timestamp.h,v 1.16 2001/03/22 04:01:14 momjian Exp $
|
||||
* $Id: timestamp.h,v 1.17 2001/09/06 03:22:42 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -177,6 +177,9 @@ extern int tm2timestamp(struct tm * tm, double fsec, int *tzp, Timestamp *dt);
|
||||
extern int timestamp2tm(Timestamp dt, int *tzp, struct tm * tm,
|
||||
double *fsec, char **tzn);
|
||||
|
||||
extern int interval2tm(Interval span, struct tm * tm, float8 *fsec);
|
||||
extern int tm2interval(struct tm * tm, double fsec, Interval *span);
|
||||
|
||||
extern Timestamp SetTimestamp(Timestamp timestamp);
|
||||
|
||||
extern void isoweek2date(int woy, int *year, int *mon, int *mday);
|
||||
|
Loading…
x
Reference in New Issue
Block a user