Comparing two dates with different Format

Hi Everyone,

I am trying the compare the Date Values from the Excel which is in the format of 25-SEP-19 (Date Format)
and the extracted date as 25 Sep 2019 (String)

The Output from the Log messages

Can anyone please advise how to convert the extracted value (25 Sep 2019) can be matched to Excel Date Value (25-SEP-19)

Much appreciated for your kind help in advance.



You can convert by using below expression.

     Convert.ToDateTime(row(“TRANSACTION_DATE”).ToString).ToString(“dd MMM yyyy”)

Hi @lakshman,

Thank you so much for your quick reply. Now its possible to change the date format.

Even though I have changed the date type I am unable to get the matched records from the Data table by using the below select method. Would you please guide me, am I doing something wrong.

I am reading the same from excel as below
Output is Source Contains No Data Rows Even though we matched exactly.


It seems like your select query only wrong. Single quotes are missing for first two column name values in that select query.


The date you are passing is not in the same format as in the datatable.

Change this dd MMM yyyy to dd-MMM-yyyy and check once. Check the amount value as well.

1 Like

Hi Lakshman,

Its worked as below even there is no Single Quote for the [OTHER NUMBER]

Smart_DT.Select(“[AMOUNT] = '”+PaymentAmount.ToString+“’ AND [OTHER NUMBER] = “+EntityID+” AND [TRANSACTION_DATE] = '”+TreatmentDate.ToString+“'”).CopyToDataTable

It seems whatever the value you are converting needs to be quoted in Single

Hi @sarathi125,

Thank you for your reply. Now Its solved


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