Dave
Dave

Reputation: 387

format dates to be used in sqlite

I have a csv file with 70,000 records and I need to compare dates.

These are currently stored for example DD/MM/YYYY

I believe that sqlite requires them to be stored YYYY-MM-DD so that I can use date functions on them.

Is there any easy way to convert the format of all of these records?

Many thanks

Upvotes: 1

Views: 301

Answers (2)

web_bod
web_bod

Reputation: 5758

Get something like Notepad++ / Textpad and do a search and replace:

Textpad    \([0-9]{2}\)/\([0-9]{2}\)/\([0-9]{4}\)
Notepad++  ([0-9]{2})/([0-9]{2})/([0-9]{4})

Replace with: \3-\2-\1 

Make sure you're searching with regular expressions/extended searching

Upvotes: 0

John Woo
John Woo

Reputation: 263933

did you try strftime('%Y-%m-%d', colNameHere)?

More Formatting Information Here

Upvotes: 1

Related Questions