Hello,

I am new and have received much information from this list so I hope I am not 
wasting bandwidth. I don't know if it is my misunderstanding or typos but 
should your sqlite3_column_int() use indexes 0,1 and 2 instead of 1, 12 and 13? 
 If this is the case, according to the docs on sqlite3_column_int() "...if the 
column index is out of range, the result is undefined."

I hope I did not misunderstand the issue.

--- On Sun, 7/17/11, marco bianchini <informa...@gmail.com> wrote:

> From: marco bianchini <informa...@gmail.com>
> Subject: [sqlite] year, month & day problem
> To: sqlite-users@sqlite.org
> Date: Sunday, July 17, 2011, 6:05 AM
> Hi all,
> call me stupid but after some days of try and a lot of
> Googleing, im still
> wondering how to solve my problem:
> i need to execute a query that updates 3 integer fields
> (AA, MM, GG) of a
> table, containing respectively today year, today month and
> today day:
> 
> update settings set AA=strftime('%Y', 'now'),
> MM=strftime('%m', 'now'),
> GG=strftime('%d', 'now')
> 
> looks working well, but later, when i read that values:
> <xcode>
>     const char *sql="select AA,MM,GG from
> settings";
>     sqlite3_stmt *statmentS;
>     if (sqlite3_prepare_v2(database, sql 
> ,-1,&statmentS, NULL)==SQLITE_OK)
> {
>         if
> (sqlite3_step(statmentS)==SQLITE_ROW) {
>             UserSettings *k =
> [UserSettings sharedUserSettings];
>            
> k.AA=sqlite3_column_int(statmentS, 1);
>            
> k.MM=sqlite3_column_int(statmentS, 12);
>            
> k.GG=sqlite3_column_int(statmentS, 13);
> ...
> </xcode>
> 
> i obtain correct values, but in inverse order:
> 
> AA (year) contains the day number
> MM (month) is correct
> GG (day) contains the year
> 
> using SQLIte Manager addons for Firefox, this query:
>  select  strftime('%Y', 'now'), strftime("%m", "now"),
> strftime("%d", "now")
> from settings
> returns correct values, running or loading value into XCode
> simulator looks
> not working and i dont know why. :'(
> 
> 
> does anyone can suggest me what to fix or check?
> thx in advance, marco
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to