---
title: As of Dates Data Block
description: "*The As of Date (AsofDates) Data Block may be edited, though it is not required to edited in order for Assette to function.* The As of Date (*AsofDates*) Data Block is an Assette System Data Block that will return the…"
url: "https://learn.assette.com/docs/as-of-dates-system-data-block/"
updated: "2024-09-18"
category: Developers / Data Blocks / Data Blocks by Category / System Data Blocks
---

# As of Dates Data Block

*The As of Date (AsofDates) Data Block may be edited, though it is not required to edited in order for Assette to function.*

The As of Date (*AsofDates*) Data Block is an Assette System Data Block that will return the previous 24 month ends, if a client wants to derive the As of Dates from an external data source, they will need to make the necessary changes to the Data Block, otherwise no changes to the As of Date (*AsofDates*) System Data Block or any dependencies.

## General Info

| Field | Value |
| --- | --- |
| Name | *AsofDates* |
| Block Category | Interface |
| Block Type | Python |
| Data Category | None |
| Output Type | Data Table |

## Dependencies

| Data Block Name | Description |
| --- | --- |
| PythonEnvForDateCalculation | Defines the imported Python modules and libraries (e.g., "import numpy as np") |
| AsOfDatesLocalDB | The As of Dates Local Database (AsOfDatesLocalDB) is used as a dependency by other Data Blocks and is designed to retrieves available As of Dates from Assette for legacy clients. This Data Block should not be edited. [[Link](https://learn.assette.com/docs/as-of-dates-local-database/)] |
| GetClientConfigLocalDB | Returns the current configurations from Assette [Link] |

## Example Definition

```
# Input Parameters
#       {
#           "Action": (string)action, [Ex: "Generate"]
#       }

nmonths = 24 # Number of months to go back
datelist = []
Output = []
Action = "Generate"
if(params.__len__()>0):
    Action = params["Action"]
    if "nmonths" in params:
        nmonths = abs(int(params["nmonths"]))

interface_method = "Local"
#interface_method=read("GetClientConfigLocalDB", {"ParamName":"InterfaceMethod"})["data"][0]["ParamValue"]
interface_df = pd.DataFrame(read("GetClientConfigLocalDB",{"ParamName":"InterfaceMethod"})["data"])

if interface_df.empty:
    interface_method="Local"
else:
    interface_method=interface_df.iloc[0]["ParamValue"]
    #interface_method=interface_df["ParamValue"]

if interface_method == "BYOD":
    """
    sample param values:{
        "nmonths": 24
    }
    """
    nmonths = 24 # Number of months to go back
    datelist = []
    Output = []

    if "nmonths" in params:
        nmonths = abs(int(params["nmonths"]))

    current_date = datetime.datetime.now()
    datelist = []
    Output = []

    # Include the current month-end date if current_date is a month-end
    current_month_end = current_date.replace(day=calendar.monthrange(current_date.year, current_date.month)[1])
    if current_date == current_month_end:
        datelist.append(current_date)

    # Append month-end dates for the previous months
    for months in range(0, nmonths):
        last_month_end = current_date.replace(day=1) - datetime.timedelta(days=1)
        datelist.append(last_month_end)
        current_date = last_month_end

    datelist.sort(reverse=True)  # Sorting the dates in descending order

    idx = len(datelist)  # Initialize the index

    for date in datelist:
        smon = "0" + str(date.month) if len(str(date.month)) == 1 else str(date.month)
        sday = "0" + str(date.day) if len(str(date.day)) == 1 else str(date.day)
        Output.append({"ID": idx, "AsOfDates": smon + "/" + sday + "/" + str(date.year)})
        idx -= 1  # decrement the index
else:
    Output = read("AsOfDatesLocalDB",{"Action":str(Action)})["data"]

response["data"] = Output
```

##

## Example Request

The As of Date System Data Block will return the previous 24 month ends, if a client wants to derive the As of Dates from an external data source, they will need to make the necessary changes to the Data Block

```
{}
```

## Example Response

```
{
    "data": [
        {
            "ID": 24,
            "AsOfDates": "06/30/2024"
        },
        {
            "ID": 23,
            "AsOfDates": "05/31/2024"
        },
        {
            "ID": 22,
            "AsOfDates": "04/30/2024"
        },
        {
            "ID": 21,
            "AsOfDates": "03/31/2024"
        },
        {
            "ID": 20,
            "AsOfDates": "02/29/2024"
        },
        {
            "ID": 19,
            "AsOfDates": "01/31/2024"
        },
        {
            "ID": 18,
            "AsOfDates": "12/31/2023"
        },
        {
            "ID": 17,
            "AsOfDates": "11/30/2023"
        },
        {
            "ID": 16,
            "AsOfDates": "10/31/2023"
        },
        {
            "ID": 15,
            "AsOfDates": "09/30/2023"
        },
        {
            "ID": 14,
            "AsOfDates": "08/31/2023"
        },
        {
            "ID": 13,
            "AsOfDates": "07/31/2023"
        },
        {
            "ID": 12,
            "AsOfDates": "06/30/2023"
        },
        {
            "ID": 11,
            "AsOfDates": "05/31/2023"
        },
        {
            "ID": 10,
            "AsOfDates": "04/30/2023"
        },
        {
            "ID": 9,
            "AsOfDates": "03/31/2023"
        },
        {
            "ID": 8,
            "AsOfDates": "02/28/2023"
        },
        {
            "ID": 7,
            "AsOfDates": "01/31/2023"
        },
        {
            "ID": 6,
            "AsOfDates": "12/31/2022"
        },
        {
            "ID": 5,
            "AsOfDates": "11/30/2022"
        },
        {
            "ID": 4,
            "AsOfDates": "10/31/2022"
        },
        {
            "ID": 3,
            "AsOfDates": "09/30/2022"
        },
        {
            "ID": 2,
            "AsOfDates": "08/31/2022"
        },
        {
            "ID": 1,
            "AsOfDates": "07/31/2022"
        }
    ],
    "errors": [],
    "success": true,
    "logs": []
}
```
