Date & Time

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

  • 0
    Certified Lead Developer

    Hi,

    I provided answers to 2 previous threads of yours which show how to create filters and calculate datetimes.

    Filter for previous month:

    Hi I need to find out if a particular date which is stored in record type is from the previous month. For example today in September I'm finding that 7th of August 2023 date (Already present in record…
    By in Discussions > General
    10 replies

    Filter for last 45 days:

    Hello, In a interface using process model I'm generating the Report in Excel using Export Data Store Entity To Excel Smart Service on Monthly and daily basis, and in smart service inside filter field…
    By in Discussions > User Interface
    7 replies

    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:

    Python
    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

    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:

    Python

    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.

  • 0
    Certified Lead Developer
    in reply to eusebiof9911

    Below the code snippet in the language whitespace:

    Could anyone create an Appian plugin to run whitespace code?