Hi Dennis,

Thanks for the code, made me think of an alternate approach.

Tried out your code and made some changes. Here is the updated version
 
select strftime('%Y-%m-%dT%H:%M:%f', localtime) ||
case
    when (strftime('%s',localtime) - strftime('%s',GMTTime)) > 0
    then '+' || strftime('%H:%M', strftime('%s',localtime) -
strftime('%s',GMTTime),'unixepoch')
    else '-' || strftime('%H:%M', strftime('%s',GMTTime) -
strftime('%s',localtime),'unixepoch')
end
from twotimes

Works fine for any time zone. 

With Regards
 
Karthick V

 
"The secret of being miserable is to have leisure to bother about whether
you are happy or not.  The cure for it is occupation."
George Bernard Shaw (1856-1950)

-----Original Message-----
From: Dennis Cote [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 28, 2006 11:04 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Time formatting

Karthick V - TLS , Chennai wrote:
> Hi everyone,
>  
> I am trying to generate a time information with the time zone offset 
> information in the UTC format
>  
> YYYY-MM-DDTHH:MM:SS.mmm+HH:MM
>  
>   
Try this:

    select strftime('%Y-%m-%dT%H:%M:%f', 'now', 'localtime') ||
        case
            when strftime('%H:%M', '12:00', 'localtime') < '12:00'
            then strftime('-%H:%M', '00:00', 'utc')
            else strftime('+%H:%M', '00:00', 'utc')
        end;

When I run this here I get:

    2006-11-28T10:29:51.091-07:00

Which is the correct timezone offset for MST.

HTH
Dennis Cote



----------------------------------------------------------------------------
-
To unsubscribe, send email to [EMAIL PROTECTED]
----------------------------------------------------------------------------
-
DISCLAIMER 
The contents of this e-mail and any attachment(s) are confidential and intended 
for the 

named recipient(s) only. It shall not attach any liability on the originator or 
HCL or its 

affiliates. Any views or opinions presented in this email are solely those of 
the author and 

may not necessarily reflect the opinions of HCL or its affiliates. Any form of 
reproduction, 

dissemination, copying, disclosure, modification, distribution and / or 
publication of this 

message without the prior written consent of the author of this e-mail is 
strictly 

prohibited. If you have received this email in error please delete it and 
notify the sender 

immediately. Before opening any mail and attachments please check them for 
viruses and 

defect.

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to