We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Read current date field format in document

How to get current date format in word document Date and time fields?


Please ZIP and upload your sample Word DOCX document (containing the date and time fields) here for testing. Please also elaborate a bit more, what date format do you expect Aspose.Words to return in this case? We will then investigate the scenario on our end and provide you more information.

Hi @awais.hafeez, I found more specifically, if the field is type FieldTime, the field.Format.DateTimeFormat is null. You can check with the attached file.
Thank You,
Charles Date Field Handling.zip (9.8 KB)


Please try running the following code with the latest (21.10) version of Aspose.Words for .NET?

Document doc = new Document("C:\\Temp\\Date Field Handling\\Date Field Handling.docx");

foreach (Field field in doc.Range.Fields)
    if (field.Type == FieldType.FieldDate)
        FieldDate date = (FieldDate)field;
        Console.WriteLine(field.Type + " -> " + date.Format.DateTimeFormat);

    if (field.Type == FieldType.FieldTime)
        FieldTime time = (FieldTime)field;
        Console.WriteLine(field.Type + " -> " + time.Format.DateTimeFormat);

It produces the following output on my end:

FieldDate -> M/d/yyyy h:mm am/pm
FieldTime ->
FieldTime -> dddd, MMMM d, yyyy

Please also check the following screenshot that was taken from inside MS Word 2019:

Hi @awais.hafeez
I understand now that Word is not sending the format over. Thank you for your time. You can close this.


In case you have further inquiries or may need any help in future, please let us know by posting a new thread in Aspose.Words’ forum.