How to compare the date with equal and +/- day

How to compare the date with equal and +/- day

For example I have the data (DOS) 2019-07-13, so i want to compare the date for following conditions.

  1. 2019-07-13 (DOS) = 2019-07-13 (Equal Date)
  2. 2019-07-13 (DOS) = 2019-07-12 (One day Minus)
  3. 2019-07-13 (DOS) = 2019-07-14 (One Day Plus)

Can anyone please guide me. Thanks in advance!

1 Like

@mukeshkala - Thanks for your inputs but when i tried iā€™m getting below warning message.
Can you please suggest what is the issue.

The DOS has to be of type DateTime.

If you are getting it in form of String - Then you will need to Convert.toDateTime(DOS).AddDays(-1).equals(text)

ā€“
Mukesh

@mukeshkala - I tried as you suggested but getting the error-
Text variable has data type = String

RemoteException wrapping System.FormatException: String was not recognized as a valid DateTime.
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
at System.Convert.ToDateTime(String value)
at lambda_method(Closure , ActivityContext )
at Microsoft.VisualBasic.Activities.VisualBasicValue`1.Execute(CodeActivityContext context)

Hi @vaibhav2.chavan,

this can do as follows

dte= DateTime.Parse(ā€œ2019-07-13ā€)-DateTime.Parse(ā€œ2019-07-14ā€)
System.TimeSpan
Result : ā€œ-1.00:00:00ā€

to get Days only you need to parse TimeSpan variable as follows
dte.Days
Integer

image

Note : DateTime parse method used to convert date into a same ground

1 Like

Please have a look at the variable values - I have kept DOS as String and Its Working for me.

Please Validate the Value in the Text variable in the below screenshot . Can you Writeline the Value of text variable and see what are your getting-

ā€“
Mukesh

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