I have a Cloud Function that connects to the Salesforce Bulk API with a select query that returns the data in JSON which then uploads to a Google Cloud bucket. The CF itself works with no issue, however the field with a date in it returns the date in milliseconds.
I'm looking for a way to convert this date from milliseconds to a readable datetime format.
def test_query():
job = bulk.create_query_job("Person", contentType='JSON')
batch = bulk.query(job, "SELECT Name, Id, Date FROM Person")
bulk.close_job(job)
while not bulk.is_batch_done(batch):
sleep(10)
for result in bulk.get_all_results_for_query_batch(batch):
result = json.load(IteratorBytesIO(result))
for row in result:
print(row)# dictionary rows
# Push data to GCS
blob = bucket.blob('PersonObj.json')
json_string = json.dumps(result)
blob.upload_from_string(json_string)
Result of one line of JSON
"Name": "John Smith",
"Id": "0011E01231fAn1BWTF",
"Date": 1550602301000
Looking to have "Date" be returned as something readable such as yyyy-mm-dd hh:mm:ss.s
Perhaps this is something that can be done using the CSV method or in BigQuery as this is ultimately where I intend to use this data.
Thank you!