vendredi 29 avril 2016

How do I convert dates in SqlLite from m/d/y to Y-%m-%d

I have a set of data that I am importing into SqlLite, but don't really have the opportunity to manipulate it before insertion. I am trying to calculate "age" of the date, but this is proving very difficult in it's current format.

I am looking for a select that I can use to update the data and then begin writing queries the way I want.

Data Samples
9/20/1983
2/18/1986
8/1/1994
5/29/1999

Desired
1983-09-20
1986-02-18
1994-08-01
1999-05-29

Once I have data in that format, I will calculate the date using the following

(strftime('%Y', 'now') - strftime('%Y', Born)) - (strftime('%m-%d', 'now') < strftime('%m-%d', BOrn))

I guess if there's a way to cast the date into the right format AND calculate the age in one query, that would save a step, but I havent been able to find a way so far.

Aucun commentaire:

Enregistrer un commentaire