ExecuteWithRegions and Date Formatting

Hi,
I have the following requirement while using ExecuteWithRegions.
If the date value has got time as : 12:00:00 AM, then the time part should be discarded, else the time part should be displayed.
I have the merge field like this:
{MERGEFIELD "FeeDate"}
What condition I can capply to the above merge field to get the result in the required format?
Thanks!

Hi Sudheer,
Thanks for your inquiry.
I’m afraid it’s not clear how exactly you expect the fields to appear. Could you please attach a document which demonstrates a couple examples of how the fields should look?
Thanks,

Thanks Adam.
If the FeeDate is 12/10/2010 11:00:00 AM in database, the merge field value should ve displayed it as 12/10/2010 11:00:00 AM.
If the FeeDate is 12/10/2010 12:00:00 AM in database, the merge field value should ve displayed as just: 12/10/2010.
How do I specify this format condition in a merge field definition?
Hope that answers your question.

Hi
Thanks for your request. I think, you can use IFieldMergingCallback to achieve this. For example see the following code:

[Test]
public void Test001()
{
    Document doc = new Document(@"Test001\in.doc");
    doc.MailMerge.FieldMergingCallback = new DateFormater();
    doc.MailMerge.Execute(new string[]
    {
        "FeeDate"
    }, new object[]
    {
        new DateTime(2011, 7, 27, 11, 0, 0)
    });
    doc.Save(@"Test001\out.doc");
}
private class DateFormater: IFieldMergingCallback
{
    public void FieldMerging(FieldMergingArgs args)
    {
        if (args.FieldName == "FeeDate")
        {
            DateTime date = (DateTime) args.FieldValue;
            if (date.TimeOfDay.TotalSeconds == 0)
                args.Text = date.ToString("MM/dd/yyyy");
            else
                args.Text = date.ToString("MM/dd/yyyy hh:mm:ss");
        }
    }
    public void ImageFieldMerging(ImageFieldMergingArgs args)
    {
        // Do nothing.
    }
}

Hope this helps.
Best regards,

Thanks.
It works perfectly.