# Data Outputs Not Working

**URL:** <https://community.hubspot.com/t/data-outputs-not-working/121798>\
**Category:** Data Hub\
**Created:** [December 3, 2024, 2:17pm UTC](https://community.hubspot.com/t/data-outputs-not-working/121798 "2024-12-03T14:17:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmedbs](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@ahmedbs](https://community.hubspot.com/u/ahmedbs)\
**Post date:** [December 3, 2024, 2:17pm UTC](https://community.hubspot.com/t/data-outputs-not-working/121798/1 "2024-12-03T14:17:36Z")

</div>

from datetime import datetime  
maintDate = ‘’  
def main(event):  
try:  
input\_fields = event.get(‘inputFields’)  
# Get the maintenance start and end dates  
maint\_start\_date = input\_fields.get(‘maint\_start\_date’)  
maint\_end\_date = input\_fields.get(‘maint\_end\_date’)  
# Check if the dates are not None and are valid datetime objects  
if maint\_start\_date is None or maint\_end\_date is None:  
raise ValueError(“Maintenance start date or end date is missing.”)

# Assuming the dates are in string format, convert them to datetime objects  
maint\_start\_date = datetime.strptime(maint\_start\_date, ‘%Y-%m-%d’)  
maint\_end\_date = datetime.strptime(maint\_end\_date, ‘%Y-%m-%d’)

# Format the dates as strings  
maintDate = maint\_start\_date.strftime(‘%Y-%m-%d’) + " to " + maint\_end\_date.strftime(‘%Y-%m-%d’)

return {  
“outputFields”: {  
“maintDate”: maint\_date  
}  
}  
except Exception as e:  
return {  
“error”: str(e)  
}  
With this above code, in the Data Outputs when I test the flow it gives me error maintDate is not defined in code.

 ![ahmedbs_0-1733235357514.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/e/9/e92010822ed9c214fe4b77e255b0883666f412ea.png)

---

<div class="post-metadata">

**Author:** ![PamCotton](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/pamcotton/32/47916_2.png) [@PamCotton](https://community.hubspot.com/u/PamCotton)\
**Post date:** [December 3, 2024, 10:42pm UTC](https://community.hubspot.com/t/data-outputs-not-working/121798/2 "2024-12-03T22:42:31Z")

</div>

Hey @ahmedbs, thank you for posting in our Community!

Looks like the issue lies in the variable name mismatch in your return statement. You defined the variable as maintDate but returned it as maint\_date. Python is case-sensitive, so maintDate and maint\_date are treated as different variables.

@Anton and @DanielSanchez do you have any recommendations for @ahmedbs matter?

Thank you,

Pam

---

<div class="post-metadata">

**Author:** ![ahmedbs](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@ahmedbs](https://community.hubspot.com/u/ahmedbs)\
**Post date:** [December 17, 2024, 7:31pm UTC](https://community.hubspot.com/t/data-outputs-not-working/121798/3 "2024-12-17T19:31:23Z")

</div>

Thanks Pam! The code got too messy and need to clean it up and figure out.
