Hello,
I need to pass the yesterday's date and a specific time to a variable of dateTime type. Basically today I want to get all the data which is saved in database yesterday. How to achieve this?
Thank you.
Discussion posts and replies are publicly visible
Hi,
I provided answers to 2 previous threads of yours which show how to create filters and calculate datetimes.
Filter for previous month:
Filter for last 45 days:
Would be very similar to the 45 day answer, except you subtract 1 day instead of 45 and pass 00:00 in the hours/minutes/seconds fields of the startDateTime and 23:59:59 in the endDateTime.
If an answer helps you, please mark it as verified so that others can find it later.
To get yesterday’s date in Python, you can use the datetime module and the timedelta() function. Here’s an example code snippet that shows how to get yesterday’s date in the format MMDDYY:
datetime
timedelta()
MMDDYY
from datetime import date, timedelta yesterday = date.today() - timedelta(days=1) yesterday_date = yesterday.strftime('%m%d%y')
In this code snippet, date.today() returns today’s date, and timedelta(days=1) subtracts one day from it, giving us yesterday’s date. The strftime() function is then used to format the date as MMDDYY. seterra
date.today()
timedelta(days=1)
strftime()
To get a specific time for yesterday’s date, you can use the datetime module and the combine() function. Here’s an example code snippet that shows how to combine yesterday’s date with a specific time:
combine()
from datetime import datetime, timedelta yesterday = datetime.now() - timedelta(days=1) specific_time = datetime.strptime('12:30:00', '%H:%M:%S').time() yesterday_specific_time = datetime.combine(yesterday.date(), specific_time)
In this code snippet, datetime.now() returns the current date and time, and timedelta(days=1) subtracts one day from it, giving us yesterday’s date and time. The strptime() function is then used to parse the specific time string 12:30:00 into a time object. Finally, the combine() function is used to combine yesterday’s date with the specific time.
datetime.now()
strptime()
12:30:00
time
Below the code snippet in the language whitespace:
Could anyone create an Appian plugin to run whitespace code?