1

I currently have a CSV file uploaded into a sqlite 3.9.0 database with a column as Period that contains date in M/D/YYYY format as TEXT. I want to do some conditional operations on the database based on dates. I am unable to recognize them as dates. How do I recognize them as dates and do the operations?

1
  • Then how can I perform those operations? Commented Sep 3, 2016 at 7:53

2 Answers 2

3

The date values must be in one of the supported date formats before you can do most operations on them.

You should configure whatever program that generates the CSV file to output the dates in a proper format. Alternatively, write a script to convert the values. If neither is possible, you could convert them with SQL statements, but SQLite does not have many string functions, so this would be not as easy.

0
0

You could use the sqllite date and time functions to convert your string to date and then you can make your comparisons.

Probably using strftime('%d/%m/%Y',[your date])

2
  • The internal date functions do not work if the format is not valid.
    – CL.
    Commented Sep 3, 2016 at 12:15
  • Created a new column based on the dates with the format YYYYMMDD as text. and could do all operations based on that. Thanks. Commented Sep 3, 2016 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.