Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6618155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:47:35+00:00 2026-05-25T20:47:35+00:00

i need some help in getting the day value of last 7 days from

  • 0

i need some help in getting the day value of last 7 days from SQLite.

i currently able to get day value from the SQLite if there is a records.

wat i need is to show the last 7 days if the guy did something.

example, if the guys only drink a beer today, it will show

drink - thur
no - wed
no - tue
no - mon
no - sun
no - sat
no - sat

example if the guys did not drink anything, it will show

no - thur
no - wed
no - tue
no - mon
no - sun
no - sat
no - sat

example if the guys drink anything during the last 7 days, it will show

no - thur
drink - wed
no - tue
no - mon
drink - sun
no - sat
no - sat

this is the SQL code

+ (void) getInitialDataToDisplay:(NSString *)dbPath {

    DrinkTabsAndNavAppDelegate *appDelegate = (DrinkTabsAndNavAppDelegate *)[[UIApplication sharedApplication] delegate];

    if (sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK) {

        const char *sql = "SELECT DATE(datetime) FROM consumed GROUP BY DATE(datetime) ORDER BY datetime DESC";
        sqlite3_stmt *selectstmt;
        if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK) {

            while(sqlite3_step(selectstmt) == SQLITE_ROW) {
                NSString *dateDrunk = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 0)];
                NSDate *theDate = [NSDate dateFromString:dateDrunk withFormat:@"yyyy-MM-dd"];
                DayOfDrinks *drinkDayObj = [[DayOfDrinks alloc] initWithDateConsumed:theDate];
                [drinkDayObj hydrateDetailViewData];
                //NSLog([NSDate stringFromDate:drinkDayObj.dateConsumed withFormat:@"yyyy-MM-dd"]);
                [appDelegate.drinksOnDayArray addObject:drinkDayObj];
                [drinkDayObj release];
            }
        }
    }
    else
        sqlite3_close(database); //Even though the open call failed, close the database connection to release all the memory.
}

DrinkHistoryTableViewController.m

if (drunked<7) {
    for (int i=drunked; i<7; i++) {


        NSString * dayString= [NSString stringWithFormat:@"Nil"];/

        [dayArray addObject:dayString];

        }
    }

    for(int i=drunked; i>0; i--) 
    {
        DayOfDrinks *drinksOnDay = [appDelegate.drinksOnDayArray objectAtIndex:i-1];

        NSString * dayString= [NSDate stringForDisplayFromDateForChart:drinksOnDay.dateConsumed];

        [dayArray addObject:dayString];//X label for graph the day of drink.

        drinksOnDay.isDetailViewHydrated = NO;

        [drinksOnDay hydrateDetailViewData];

        NSNumber *sdNumber =  drinksOnDay.standardDrinks; // pass value over to Standard Drink Numbers

        //[sdArray addObject: sdNumber]; 

        float floatNum = [sdNumber floatValue]; // convert sdNumber to foat

        [sdArray addObject:[NSNumber numberWithFloat:floatNum]];//add float Value to sdArray
}

can anybody help to answer my question thanks a lot.

Des

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:47:36+00:00Added an answer on May 25, 2026 at 8:47 pm

    Update your query with this and try out :

    "SELECT DATE(datetime) FROM consumed GROUP BY DATE(datetime) ORDER BY datetime DESC Limit 7"
    

    You will get last 7 days information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently using json-framework and need some help though parsing some JSON i'm getting
I need some help getting data from several tables. This is the tables I
I need some help in getting this right, problem Write a function which takes
Hey all i am in need of some help getting my code working correctly
I need some help in understanding what is happening here .I am getting a
I need some help. Here's what I'm getting right now: img ref I need
Hi I need some help on getting started with creating my first algorithm; I
Hello I need some help getting my mysql correct. I need to select one
I need some help in getting the name of the most recent directory in
Guys i need some help here , im getting this error here at the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.