Hi @Baiju EP ,
The reason for not working should be that the date format is not correct.
DateTime Struct:Represents an instant in time, typically expressed as a date and time of day.
https://learn.microsoft.com/en-us/dotnet/api/system.datetime?view=net-7.0
You can use Convert.ToDateTime
to convert a specified value to a DateTime value.
https://learn.microsoft.com/en-us/dotnet/api/system.convert.todatetime?view=net-7.0
DateTime data1 = Convert.ToDateTime(dttxt.Text);
datetxt.text (selected date) -1 (previous date data)
Are you trying to get the previous day of the date? You can use the following code:
DateTime data1 = Convert.ToDateTime(dttxt.Text).AddDays(-1);
You can check the value of dttxt.Text at a breakpoint.
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.