How to Remove Time format from Docx?

Hi Everyone,

In excel i have date like “01-july-2019”.when the time am writing that in word it returns “07/01/2019 00:00:00”.how can remove that time format and how can i get the date same like as excel date.
help me

Thanks in Advance
Krishnareddy

yes of course we usually get full datetime format when we get from a excel
so to get the required string alone we can use a simple substring method like this
if we are getting like this from a for each row loop
row(“yourcolumnname”).ToString.SubString(0,10) \the output would be 07/01/2019 alone

if we want in same format as in excel then and if we are sure that the format is
“MM/dd/yyyy hh:m:ss” then
Datetime.ParseExact(row(“yourcolumnname”).ToString.Substring(0,10),“MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MMM-yyyy”)
\ where the output would be 01-Jun-2019
or if thats not the format then we need to mention the same format as we get from the excel (we can check that with a write line activity that shows the format in output panel)
here in the highlighted area (first ten characters of date format alone as we dont need the timestamp)
Datetime.ParseExact(row(“yourcolumnname”).ToString.Substring(0,10),“MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MMM-yyyy”)

hope this would help you
Kindly try this and let know for any queries or clarification
Cheers @krishnareddy

2 Likes

@Palaniyappan Thanks Bro…

1 Like

Cheers @krishnareddy

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