Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use between with 2 dates #257

Closed
fernando-cg opened this issue Oct 11, 2022 · 1 comment
Closed

Use between with 2 dates #257

fernando-cg opened this issue Oct 11, 2022 · 1 comment
Labels

Comments

@fernando-cg
Copy link

fernando-cg commented Oct 11, 2022

Hi im triyin to use between function to search cases between 2 dates and i don't revice any alert

now = datetime.datetime.now() - datetime.timedelta()
now = int(round(now.timestamp()))
before = datetime.datetime.now() - datetime.timedelta(minutes=10)
before = int(round(before.timestamp()))

print(datetime.datetime.fromtimestamp(now))

print(datetime.datetime.fromtimestamp(before))
query = And(Between('date', before,now))

response = api.find_alerts(query=query)
print(response.text)

I Have cases at the time i'm searching

@Kamforka Kamforka added the 1.x label Oct 21, 2022
@Kamforka
Copy link
Collaborator

@fernando-cg TheHive is handling timestamps in millisecond precision, Python is handling them as floats and the integer part is with second precision, so you should multiply by 1000:

ow = datetime.datetime.now() - datetime.timedelta()
now = int(round(now.timestamp())) * 1000
before = datetime.datetime.now() - datetime.timedelta(minutes=10)
before = int(round(before.timestamp())) * 1000

Something like the above should help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants