How to convert date from MM/DD/YYYY to YYYY-MM-DD format?

Hello,

As my title states, I need help converting from MM/DD/YYYY HH:MM:SS to YYYY-MM-DD format. Please help! :slight_smile:

Thank you!

Hi,

Can you try the following expression?

DateTime.Parse(yourDateString).ToString("yyyy-MM-dd")

image

Regards,

Hi, thank you for your response! I have a follow up question - let’s say I will need to sometimes subtract this date -1day or -90 days, where I am pulling the number from the config file, how would I do it?

Hi,

Can you try to add .AddDays(-90) for eaxmple as the following?

DateTime.Parse(yourDateString).AddDays(-90).ToString("yyyy-MM-dd")

image

Regards,

What if the -90 value is being extracted from the config file as it needs to be customizable?

I am receiving an error when storing the value (-90) that I am extracting from config file into a string

Can you try as the following?

DateTime.Parse(dateTimeString).AddDays(CInt(in_Config("someKey").ToString)).ToString("yyyy-MM-dd")
1 Like

It works, thank you so much!

1 Like