×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    21

    TTime.Parse and microseconds

    Hi,

    I'm doing some DB stuff that uses the TTime as the column's key, so i need to use a WHERE datetime=#time# clause.

    The problem i am having is that it seems TTime.Parse (which the SQL stuff for datetimes is based upon) doesnt bother calculating the microseconds part. it always seems to be zero.

    The format string i am using is:
    _LIT(KDateFormat,"%M%Y%D%/0%1%/1%2%/2%3%/3 %H:%T:%S.%C");

    which out puts it in the format
    dd/mm/yyyy hh:nn:ss.cccccc

    when i do a TTime.Parse on that, the microseconds part is zero. unfortunately that means the equality check fails.


    can someone confirm this does anyone have a solution that doesnt involve just setting the microseconds to zero when its stored in the db?

  2. #2
    Super Contributor
    Join Date
    May 2005
    Location
    Hyderabad,India
    Posts
    704

    Re: TTime.Parse and microseconds

    Hi,

    Use

    TTime time;
    TInt iMs;
    iMs=time.DateTime().MicroSecond();


    by this u can get no.of microseconds from TTime.

    regards,
    eswar

  3. #3
    Registered User
    Join Date
    Feb 2006
    Posts
    21

    Re: TTime.Parse and microseconds

    Hi,

    Thanks for your reply. but the problem is the way the SQL statements.

    I need to do SELECT column1, column2 FROM datetable WHERE datetime=#time#

    the problem comes down to the fact you have to provide #time# as a string that can be interpretted by TTime.Parse.. and it seems TTime.Parse doesnt bother with microseconds

    looks like i'll have to be using native symbian C++ table commands

  4. #4
    Super Contributor
    Join Date
    May 2005
    Location
    Hyderabad,India
    Posts
    704

    Re: TTime.Parse and microseconds

    Hi,

    Take string like this

    _LIT(KDateFormat,"%M%Y%D%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%.%*C6%:3%+B");


    regards,
    eswar

  5. #5
    Registered User
    Join Date
    Feb 2006
    Posts
    21

    Re: TTime.Parse and microseconds

    still no joy the format string you gave essentially gives the same text, and when you TTime.Parse it, the resulting TTime value is still different

  6. #6
    Super Contributor
    Join Date
    May 2005
    Location
    Hyderabad,India
    Posts
    704

    Re: TTime.Parse and microseconds

    Hi,

    "%*C6%" string in that format gives the six digits in microseconds field. u check it with other digits(1-6) also.

    regards,
    eswar

  7. #7
    Registered User
    Join Date
    Feb 2006
    Posts
    21

    Re: TTime.Parse and microseconds

    ok. try this code. I'm using the 2.1 SDK for Visual Studio, and when i step through this code in visual studio, it doesnt not bother to parse the microseconds value.

    when you use SQL statements, you cannot change how they are evaluated, so an SQL statement that makes a equality comparison that requires microsecond accuracy will fail due to this.

    Code:
    	_LIT(KDateFormat,"%M%Y%D%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%.%*C6%:3%+B");
    	//_LIT(KDateFormat,"%M%Y%D%/0%1%/1%2%/2%3%/3 %H:%T:%S.%C");
    
    	TDateTime inputDateTime(2006,EJanuary,2,5,6,7,123456);
    	TTime inputTime(inputDateTime);
    	TBuf<100> formatted;
    	inputTime.FormatL(formatted,KDateFormat);
    
    	TTime outputTime;
    	outputTime.Parse(formatted);
    	TDateTime outputDateTime=outputTime.DateTime();
    	if (outputDateTime.MicroSecond()==0) {
    		// always happens
    		TBool failedToParseProperly=ETrue;
    	}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •