Save Only Date

I have word document and my bot replace the date after replacing date bot automatically generate
the time.
Example-21/12/2020 00:00:00
I want only the date in document.How can solve this issue.

HI @Himanshu_Pratap_Rana

You Can use various method

System.text.RegularExpressions.Regex.Replace("21/12/2020 00:00:00","\d{2}:\d{2}:\d{2}","").Trim
Split("21/12/2020 00:00:00"," ")(0)

Regards
Sudharsan

@Himanshu_Pratap_Rana


image

DateTime.ParseExact("21/12/2020 00:00:00","dd/MM/yyyy hh:mm:ss",System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).ToString("dd/MM/yyyy")

Regards
Sudharsan

Hi @Himanshu_Pratap_Rana

Simply You can convert into CDate

CDate("21/12/2020 00:00:00").Tostring("dd/MM/yyyy")

Regards
Gokul

Hello @Himanshu_Pratap_Rana
Try this below expression

DateTime.ParseExact("21/12/2020 00:00:00","dd/MM/yyyy HH:mm:ss",System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")

image

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.