Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-25-2011, 11:10 AM   #1 (permalink)
learner2011
 
Join Date: Mar 2011
Posts: 115
ashwinr87 is on a distinguished road
Default Reading Date from database in Ipad

Hi,

say for example I have the following piece of code with which I retrieve the date from the database

Code:
 DateLabel.text = [CommonHelper getDateString:objSample.startDate :@"MM/dd/yyyy"];
where

i) objSample is an object of my Sample entity

ii) startDate is an attribute in the Sample entity declared as
Code:
@property (nonatomic, retain) NSDate * startDate;
iii)CommonHelper is another file where I have the getDateString: function as below,
Code:
+ (NSString *) getDateString:  (NSDate *) date: (NSString *) format
  {
    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
    [dateFormat setDateFormat:format]; 
    NSString *dateStr = [dateFormat stringFromDate:date];
    [dateFormat release];
    return dateStr;
   }
Using Sqlite Database Browser, if I enter the value as "04/23/1999" to the Sample's startDate attribute , the value which is displayed in DateLabel.text is a totally different value and if I enter a value such as "76851234", the value which is displayed in DateLabel.text is "05/23/2001".

Since I am new in dealing with database, I am unable to understand why this happens... Would someone be able to tell me why this happens? and is there a way I can directly enter the date into the database using SQLite Database Browser so that that date is displayed?

is the format of the date I enter into the SQLite database browser a "Unix Date Format"? if so, how would I be able to convert the date into unix date format so that I know for certain what would be the exact date I would be displaying on my app...
ashwinr87 is offline   Reply With Quote
Old 04-25-2011, 11:18 AM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

Can you show the code of where you are setting the text value in the label?
smithdale87 is offline   Reply With Quote
Old 04-25-2011, 11:33 AM   #3 (permalink)
learner2011
 
Join Date: Mar 2011
Posts: 115
ashwinr87 is on a distinguished road
Default

yeah.. its there at the beginning of the post... but anyway here it is again
Code:
  DateLabel.text = [CommonHelper getDateString:objSample.startDate :@"MM/dd/yyyy"];

Quote:
Originally Posted by smithdale87 View Post
Can you show the code of where you are setting the text value in the label?
ashwinr87 is offline   Reply With Quote
Reply

Bookmarks

Tags
core data, ios 4, ipad app, nsdateformatter, sqlite database

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 353
11 members and 342 guests
dansparrow, iOS.Lover, lorrettaui53, Nobbsy, oztemel, pbart, PlutoPrime, samdanielblr, sledzeppelin, thephotographer, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,120
Posts: 402,897
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:51 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0