anjasing
(Anjali)
March 12, 2024, 10:02am
1
I am retrieving one date from Excel as ExcelDate and another date as todayDate variable. Both are in string variable. I want to compare them in if condition.
If (excel date is not equal to todaydate)
How can I do it??
for e.g.
exceldate =“12-03-2024”
todayDate =“12-03-2024”
How can I check here
ppr
(Peter Preuss)
March 12, 2024, 10:04am
2
depending on the format we parse the strings into a dateTime and compare both at DateTime base
1 Like
mkankatala
(Mahesh Kankatala)
March 12, 2024, 10:11am
4
Hi @anjasing
Check the below Condition -
- Condition -> DateTime.ParseExact(CurrentRow("Column name").toString, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture).equals(DateTime.ParseExact(todayDate.toString, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture))
If the exceldate is also variable then use below,
- Condition -> DateTime.ParseExact(exceldate.toString, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture).equals(DateTime.ParseExact(todayDate.toString, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture))
Hope it helps!!
1 Like
anjasing
(Anjali)
March 12, 2024, 10:14am
5
@lrtetala ,
Can you please confirm if datatype of Excel Date and Today Date variable is System.DateTime?
cz it’s giving me cultureinfo is missing or not decalred
issue
lrtetala
(Lakshman Reddy)
March 12, 2024, 10:15am
6
@anjasing
Try this
excelDate = DateTime.ParseExact(excelDateStr, “dd-MM-yyyy”, System.Globalization.CultureInfo.InvariantCulture)
todayDate = DateTime.ParseExact(todayDateStr, “dd-MM-yyyy”, System.Globalization.CultureInfo.InvariantCulture)
1 Like
Hi,
Input:-
Output:-
Xaml File:-
date comparision forum.zip (3.0 KB)
If it works for you, please mark it as a solution.
Thanks
1 Like
mkankatala
(Mahesh Kankatala)
March 12, 2024, 10:17am
8
Okay @anjasing
Then check the below one,
- Condition -> DateTime.ParseExact(ExcelDate.toString, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture).equals(TodayDate)
In the above ExcelDate is System.String datatype variable and TodayDate is in System.DateTime datatype variable
Hope you understand!!
1 Like
lrtetala
(Lakshman Reddy)
March 12, 2024, 10:22am
9
@anjasing
DateTime.ParseExact("12-03-2024","dd-MM-yyyy",System.Globalization.CultureInfo.InvariantCulture)
DateTime.ParseExact("12-03-2024","dd-MM-yyyy",System.Globalization.CultureInfo.InvariantCulture)
1 Like
system
(system)
Closed
March 15, 2024, 10:22am
10
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.