Hi @Baiju EP ,
I think you can get the year through DateTime.Year Property directly based on the date from datetxt.text.
https://learn.microsoft.com/en-us/dotnet/api/system.datetime.year?view=net-7.0
yeartxt.Text = Convert.ToDateTime(datetxt.Text).Year.ToString()
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.