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 774317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:06:42+00:00 2026-05-14T19:06:42+00:00

Here I had a problem with the date formatters actually I had an option

  • 0

Here I had a problem with the date formatters actually I had an option to search events based on the date.for this Im comparing the date with the date store in the database and getting the event based on the date for this I wrote the code as follows:

-(NSMutableArray*)getSearchAllLists:(EventsList*)aEvent
{
[searchList removeAllObjects];
EventsList *searchEvent = nil;
const char* sql;
NSString *conditionStr = @" where ";
if([aEvent.eventName length] > 0)
{
    NSString *str = @"'%";
    str = [str stringByAppendingString:aEvent.eventName];
    str = [str stringByAppendingString:@"%'"];
    conditionStr = [conditionStr stringByAppendingString:[NSString stringWithFormat:@" eventName like %s",[str UTF8String]]];
}
if([aEvent.eventWineName length]>0)
{
    NSString *str = @"'%";
    str = [str stringByAppendingString:aEvent.eventWineName];
    str = [str stringByAppendingString:@"%'"];
    if([aEvent.eventName length]>0)
    {
        conditionStr = [conditionStr stringByAppendingString:[NSString stringWithFormat:@" and (wineName like %s)",[str UTF8String]]];
    }
    else
    {
        conditionStr = [conditionStr stringByAppendingString:[NSString stringWithFormat:@"wineName like %s",[str UTF8String]]];
    }
}
if([aEvent.eventVariety length]>0)
{
    NSString *str = @"'%";
    str = [str stringByAppendingString:aEvent.eventVariety];
    str = [str stringByAppendingString:@"%'"];
    if([aEvent.eventName length]>0 || [aEvent.eventWineName length]>0)
    {
        conditionStr = [conditionStr stringByAppendingString:[NSString stringWithFormat:@" and (variety like %s)",[str UTF8String]]];
    }
    else
    {
        conditionStr = [conditionStr stringByAppendingString:[NSString stringWithFormat:@"variety like %s" ,[str UTF8String]]];
    }
}
if([aEvent.eventWinery length]>0)
{
    NSString *str = @"'%";
    str = [str stringByAppendingString:aEvent.eventWinery];
    str = [str stringByAppendingString:@"%'"];
    if([aEvent.eventName length]>0 || [aEvent.eventWineName length]>0 || [aEvent.eventVariety length]>0)
    {
        conditionStr = [conditionStr stringByAppendingString:[NSString stringWithFormat:@" and (winery like %s)",[str UTF8String]]];
    }
    else
    {
        conditionStr = [conditionStr stringByAppendingString:[NSString stringWithFormat:@"winery like %s" ,[str UTF8String]]];
    }
}
if(aEvent.eventRatings >0)
{
    if([aEvent.eventName length]>0 || [aEvent.eventWineName length]>0 || [aEvent.eventWinery length]>0 || [aEvent.eventVariety length]>0)
    {
        conditionStr = [conditionStr stringByAppendingString:[NSString stringWithFormat:@" and ratings = %d",aEvent.eventRatings]];
    }
    else
    {
        conditionStr = [conditionStr stringByAppendingString:[NSString stringWithFormat:@" ratings = %d",aEvent.eventRatings]];
    }
}
if(aEvent.eventDate >0)
{
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
    [dateFormatter setDateFormat:@"dd-MMM-yy 23:59:59"];
    NSString *dateStr = [dateFormatter stringFromDate:aEvent.eventDate]; 
    NSDate *date = [dateFormatter dateFromString:dateStr];
    [dateFormatter release];
    NSTimeInterval interval = [date timeIntervalSinceReferenceDate];
    printf("\n Interval in advance search:%f",interval);
    if([aEvent.eventName length]>0 || [aEvent.eventWineName length]>0 || [aEvent.eventWinery length]>0 || aEvent.eventRatings>0 || [aEvent.eventVariety length]>0)
    {
        conditionStr = [conditionStr stringByAppendingString:[NSString stringWithFormat:@" and eventDate = %f",interval]];
    }
    else
    {           
        conditionStr = [conditionStr stringByAppendingString:[NSString stringWithFormat:@" eventDate = %f",interval]];
    }
}

NSString* queryString= @" select * from event";
queryString = [queryString stringByAppendingString:conditionStr];
sqlite3_stmt* statement;
sql = (char*)[queryString UTF8String];
if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL) != SQLITE_OK)
{
    NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
}
sqlite3_bind_text(statement, 1, [aEvent.eventName UTF8String],  -1, SQLITE_TRANSIENT);
sqlite3_bind_text(statement, 2, [aEvent.eventWineName UTF8String],  -1, SQLITE_TRANSIENT);
sqlite3_bind_text(statement, 3, [aEvent.eventVariety UTF8String],  -1, SQLITE_TRANSIENT);
sqlite3_bind_text(statement, 4, [aEvent.eventWinery UTF8String],  -1, SQLITE_TRANSIENT);
sqlite3_bind_int(statement, 5,aEvent.eventRatings);
sqlite3_bind_double(statement,6, [[aEvent eventDate]  timeIntervalSinceReferenceDate]);
while (sqlite3_step(statement) == SQLITE_ROW) 
{
    primaryKey = sqlite3_column_int(statement, 0);      
    searchEvent = [[EventsList alloc] initWithPrimaryKey:primaryKey database:database];
    [searchList addObject:searchEvent];
    [searchEvent release];
}
sqlite3_finalize(statement);
return searchList;
}

Here I compared the interval value in the database and the date we are searching and Im getting the different values and results were not found.

Guy’s help me to get rid of this.

Anyone’s help will be much appreciated.

Thank you
Monish Calapatapu.

  • 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-14T19:06:42+00:00Added an answer on May 14, 2026 at 7:06 pm

    I’m finding it hard to follow the problem. Can you re-edit the sample code down to just the lines that show the problem? Also an example of what values you are inputting and getting out would help as well.

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

Sidebar

Ask A Question

Stats

  • Questions 545k
  • Answers 545k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • added an answer Well, start off by thinking of which bits of data… May 17, 2026 at 9:17 am
  • added an answer For this task it is a good idea to use… May 17, 2026 at 9:15 am
  • added an answer This is exactly how the Skyhook database (built into many… May 17, 2026 at 9:15 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I was wondering if anyone here had some experience writing this type of script
I had a problem getting a VB.NET web service client to receive the response
We had a discussion here at work regarding why fread() and fwrite() take a
I had a similar question answered Here There is a slight twist to the
We've had an ongoing need here that I can't figure out how to address
yesterday you had taught me to query record history within a time range here
What memory leak detectors have people had a good experience with? Here is a
Here's a problem I ran into recently. I have attributes strings of the form
Ok, I need help. This is my first question here. Background: I am working
i'm using jquery in report section in my asp.net mvc project.But i had problem

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.