Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql General > ecpg-timestamp-...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 15215 of 17602
Post > Topic >>

ecpg-timestamp- interval problem V8.2.x

by Paul.Tilles@[EMAIL PROTECTED] (paul tilles) Apr 8, 2008 at 09:40 AM

A colleague of mine is working with the following code (postgres Version 
8.2.4):

#include <stdio.h>
#include <stdlib.h>
#include "pgtypes_timestamp.h"
#include "pgtypes_interval.h"

EXEC SQL INCLUDE sqlca;

main(argc, argv)
   int argc;
   char *argv[];
{
 timestamp dt1st, dt2nd;
 interval *int_day, *int_pt;

 char timebeg[40];
 char timeend[40];
 int rc;

 strcpy(timebeg,"2008-04-01");
 strcpy(timeend,"2008-04-05");

 printf("timebeg: %s\n", timebeg);
 printf("timeend: %s\n", timeend);

 dt1st=PGTYPEStimestamp_from_asc(timebeg,NULL);
 dt2nd=PGTYPEStimestamp_from_asc(timeend,NULL);
 int_day=PGTYPESinterval_from_asc("02 01:02:03", NULL);
 printf("int_day : %s\n", PGTYPESinterval_to_asc(int_day));

 rc=PGTYPEStimestamp_sub(&dt2nd, &dt1st, int_pt);
 printf("rc, date2 - date1 = %d, %s\n", rc,
PGTYPESinterval_to_asc(int_pt));
 exit(0);
}

--------------------------------------------------------------------------------------------
The output is

timebeg: 2008-04-01
timeend: 2008-04-05
int_day : @[EMAIL PROTECTED]
 2 days 1 hour 2 mins 3 secs
rc, date2 - date1 = 0, @[EMAIL PROTECTED]
 1 sec ago

--------------------------------------------------------------------------------------------

The result of the subtraction of the the two timestamps is not correct.


What's going on?

TIA.

Paul Tilles

-- 
Sent via pgsql-general mailing list (pgsql-general@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
 




 2 Posts in Topic:
ecpg-timestamp- interval problem V8.2.x
Paul.Tilles@[EMAIL PROTEC  2008-04-08 09:40:17 
Re: ecpg-timestamp- interval problem V8.2.x
tgl@[EMAIL PROTECTED] (T  2008-04-08 11:02:03 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 19:57:31 CST 2008.