Quantcast

Convert a string to Timestamp using SQLite

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Convert a string to Timestamp using SQLite

manohar s
Hi all,
I have a string of type "080110 17:32:34" where.08 refers year in yy format
and 01 refers to month(mm) jan and 10  refers date(dd).
I want to insert this into SQLite as any standard timestamp format such as
YYYY-mm-dd HH:MM:SS or unixepoch etc.. Is it possible to
do this?

Please Help
Thanks in advance
Manohar.s

--
hope is the only thing which keeps us all happy
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Convert a string to Timestamp using SQLite

Igor Tandetnik
manohar s <[hidden email]> wrote:
> I have a string of type "080110 17:32:34" where.08 refers year in yy
> format and 01 refers to month(mm) jan and 10  refers date(dd).
> I want to insert this into SQLite as any standard timestamp format
> such as YYYY-mm-dd HH:MM:SS or unixepoch etc.. Is it possible to
> do this?

Can't you just perform a few simple string manipulations in your
application to turn 080110 into 2008-01-10?

Igor Tandetnik


-----------------------------------------------------------------------------
To unsubscribe, send email to [hidden email]
-----------------------------------------------------------------------------

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: Convert a string to Timestamp using SQLite

Michael Hooker
In reply to this post by manohar s
>>> Can't you just perform a few simple string manipulations in your
>>> application to turn 080110 into 2008-01-10?<<

Exactly what I was about to suggest.  I do it the other way around.  One of
my table columns has to contain dates, some of which are incomplete, for
example "March 2001" [the table stores details of photos and many people
don't keep any sensible record of when they take their photos].  So I store
it as "200103--" and then manipulate this string when it comes to screen
display.  It's a very neat solution which both gives me a reasonably
sortable date column in the table and enables a simple custom routine in my
php online application to display the date in my website as "on 01 January
1986" (19860101), "in March 2001" (200103--), "in 2006" (2006----) or even
"in the sixties" (196-----) or "on date unknown" (--------).  Over the years
I've got really fed up with database and spreadsheet programs that refuse to
accept an incomplete date in a date column - I can see why they do it, but
in real life data is often incomplete so you have to find other ways.

Michael Hooker

On 14/01/2008 15:48:32, Igor Tandetnik ([hidden email]) wrote:

> manohar s <[hidden email]> wrote:
> > I have a string of type "080110 17:32:34" where.08 refers year in yy
> > format and 01 refers to month(mm) jan and 10  refers date(dd).
> > I want to insert this into SQLite as any standard timestamp format
> > such as YYYY-mm-dd HH:MM:SS or unixepoch etc.. Is it possible to
> > do this?
>
> Can't you just perform a few simple string manipulations in your
> application to turn 080110 into 2008-01-10?
>
> Igor Tandetnik
>
>
> -----------------------------------------------------------------------------
> To unsubscribe, send email to [hidden email]
> -----------------------------------------------------------------------------


-----------------------------------------------------------------------------
To unsubscribe, send email to [hidden email]
-----------------------------------------------------------------------------

Loading...