Hi all,
I'm trying to grab the day of date from my agenda table where the month is current month.
However this NSString assumes that.. %d %m and %i must be set.
However the %d should say, return day of month from date
and %m should say, return month from date
Here I try to get all days, from my agenda where month is equal to >month< (int of current month, or the month I'm looking at in my agenda)
---
Resolved:
I had to do the query setup in 2 steps.
---
Now I try to store these 'days' into an NSArray. Like this:
But this needs to be done programaticly.
This is giving me back an different number every time:
(p.s. DISTINCT is like >DISTINCT< because I get blocked due SQL Injection :-/... woops ;D )
I'm trying to grab the day of date from my agenda table where the month is current month.
Code:
[NSString stringWithFormat: @"SELECT strftime('%d', agenda_datum) as dayOfMonth FROM agenda_items WHERE strftime('%m', agenda_datum) = '%i'", month]
However this NSString assumes that.. %d %m and %i must be set.
However the %d should say, return day of month from date
and %m should say, return month from date
Here I try to get all days, from my agenda where month is equal to >month< (int of current month, or the month I'm looking at in my agenda)
---
Resolved:
I had to do the query setup in 2 steps.
Code:
NSString *tempQuery = @"SELECT >DISTINCT< strftime('%d', agenda_datum) as dayOfMonth FROM agenda_items WHERE strftime('%m', agenda_datum) = ";
NSString *finalQuery = [NSString stringWithFormat: @"%@'%i'", tempQuery, month];
Now I try to store these 'days' into an NSArray. Like this:
Code:
NSArray *dates = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:5], nil];
This is giving me back an different number every time:
Code:
NSString *tempQuery = @"SELECT >DISTINCT< strftime('%d', agenda_datum) as dayOfMonth FROM agenda_items WHERE strftime('%m', agenda_datum) = ";
NSString *finalQuery = [NSString stringWithFormat: @"%@'%i'", tQuery, month];
NSArray *markDays = [[NSArray alloc] initWithArray:[dbManager loadDataFromDB:finalQuery]];
NSInteger indexOfDayOfMonth = [dbManager.arrColumnNames indexOfObject:@"dayOfMonth"];
NSMutableArray *markedDays = [[NSMutableArray alloc] initWithObjects: nil];
for(int a=0; a<markDays.count; a++) {
int mDay = (int)[[markDays objectAtIndex: a] objectAtIndex: indexOfDayOfMonth];
[markedDays addObject: [[markDays objectAtIndex: a] objectAtIndex: indexOfDayOfMonth]];
}
(p.s. DISTINCT is like >DISTINCT< because I get blocked due SQL Injection :-/... woops ;D )
Last edited: