zawwinmaung
zawwinmaung

Reputation: 21

SQLite Extract Month From Column

I have a column of data with this date format mm/dd/yyyy. I would like to covert to this to the format yyyy-mm-dd for (SQLite usage). How could I achieve this?

UPDATE Table_Name 
SET Column_Name = 'yyyy-mm-dd' format

I have tried substr, ltrim, rtrim (None of this work for my case).

My data are dynamic.

Sample

Column_Name
6/1/2004
06/25/2004
7/1/2003
6/1/2004
6/1/2004
09/19/2003
09/30/2003
09/30/2003
09/30/2003
09/30/2003

The Goal: Extract only month from this Column (Without displaying unnecessary stuff)

Thank you.

Upvotes: 2

Views: 10152

Answers (1)

kiwi209
kiwi209

Reputation: 301

The syntax for extracting a specific date element from a date field is to use strftime. SELECT strftime('%m', Column_Name) AS month which is your second question. For reconstituting the date data you could use (at least in JavaScript) substr to split the date out then format it as you require. Also see this post:Get month from DATETIME in sqlite

Upvotes: 1

Related Questions