0

Is there any way to query date and get timestamp instead of datetime.datetime object in sqlalchemy using python 2.7?

Omar
  • 309
  • 5
  • 17
  • 1
    Does this answer your question? [Convert datetime to unix timestamp in SQLAlchemy model before executing query?](https://stackoverflow.com/questions/38357352/convert-datetime-to-unix-timestamp-in-sqlalchemy-model-before-executing-query) – rfkortekaas Mar 11 '21 at 12:52
  • ? `dt = datetime.datetime(2021, 3, 11) dt.timestamp() 1615449600` – Adrian Klaver Mar 11 '21 at 15:15
  • I'm getting an Attribute Error. – Omar Mar 11 '21 at 15:34
  • You will need to show the code you are running to get a useful answer. Please include it as an UPDATE to your original question. – Adrian Klaver Mar 11 '21 at 18:04

1 Answers1

0

This seems to have worked for me.

import time
time.mktime(data.date.timetuple())
Omar
  • 309
  • 5
  • 17