Re: problem to insert data

From: Merrill & Michele (beckjensen_at_comcast.net)
Date: 11/25/04


Date: Thu, 25 Nov 2004 10:33:59 -0600


"os2" <marcpirat@yahoo.com> wrote in message
news:844b0dba.0411250812.c4ccfb7@posting.google.com...
> hi
>
> i have an insertion problem with my rtu table
> datatype for date1 field is: datetime
>
> i try to insert local date to the database (mysql)
>
> source code
>
> struct tm *date;
> struct timeval begin;
> struct timeval end;
>
> gettimeofday(&end, NULL);
> date = localtime(&end.tv_sec);
> strftime(datestr, 128, "%F %T", date);
> printf("date str %s", datestr);
> snprintf(query, 512, "INSERT INTO rtu (date1,duration,sensorid)
> VALUES(%s,%d,%d)",datestr, 0, 0);
> res=mysql_query(&my_connection,query);
>
> res display 1 (a error)
>
> datestr display me
> 2004-11-25 15:52:55
>
>
> query variable return
> INSERT INTO rtu (date1,duration,sensorid) VALUES(2004-11-25
> 15:56:11,0,0)
>
>
> any idea?
While I certainly don't possess the omniscience that the loudest voicest
around here do, I'm going to guess that some of your function calls lie
outside the ANSI/ISO Standard. If so, expect four more posts, progessively
shrill, telling you the same thing. MPJ



Relevant Pages

  • Re: Input Mask on Date for Year or Month Only
    ... If you wish to use the DateTime functions, then the field's datatype ... format, the stored value must contain the day as well. ... mm-yyyy format, i.e. 08/2008 or 08-2008. ...
    (microsoft.public.access.gettingstarted)
  • Bulk Insert - How to represent nulls in .txt input file?
    ... I have a table that I'm loading via .txt file input. ... One of the columns has a datatype of datetime. ... way to pass a null to a datetime field that allows nulls. ...
    (microsoft.public.sqlserver.dts)
  • Re: Converting and formatting DATE field
    ... SQLServer does not have a date only datatype, therefore it will store a time ... If you don't specify the time portion when the datetime is inserted ... > I would like to be able to format this date and show only ...
    (microsoft.public.sqlserver.programming)
  • Re: Input Mask on Date for Year or Month Only
    ... Can I use an input mask to caputre only the year or only the month? ... If you wish to use the DateTime functions, then the field's datatype ... format, the stored value must contain the day as well. ...
    (microsoft.public.access.gettingstarted)
  • Re: Bulk Insert - How to represent nulls in .txt input file?
    ... >One of the columns has a datatype of datetime. ... >way to pass a null to a datetime field that allows nulls. ... I just tried,, (no quotes) and that worked. ...
    (microsoft.public.sqlserver.dts)