Select to view content in your preferred language

Date and Time format from SQLite Database

803
1
Jump to solution
10-12-2022 12:16 PM
MaryGraceMcClellan
New Contributor III

I have survey data that was exported from a SQLite database into a CSV so it could be appended to the survey dataset. The process works okay, but I  am unsure how to convert the time and date fields. They are not datetime types, one is specifically a date field, and the other is time. An example of the data is below: 

"Collect_Date": 1657987200000
"Collect_Time": 1657987800000

Has anyone converted from this format before? I thought it might be UTC or epoch, but the times seem off when I run them through an online converter. 

Thanks in advance! 

0 Kudos
1 Solution

Accepted Solutions
MaryGraceMcClellan
New Contributor III

Edit -- here is the python script I used to solve this issue, where x is the long integer being output:

 

from datetime import datetime

d = int(x/1000)
date = datetime.utcfromtimestamp(d).strftime('%m/%d/%Y %H:%M:%S')

 

 

View solution in original post

1 Reply
MaryGraceMcClellan
New Contributor III

Edit -- here is the python script I used to solve this issue, where x is the long integer being output:

 

from datetime import datetime

d = int(x/1000)
date = datetime.utcfromtimestamp(d).strftime('%m/%d/%Y %H:%M:%S')