ch460960
(Ch460960)
1
Hi all, I need to check difference between current date with input date(MM/dd/yyyy) format. If difference is greater than 1 day, need to log message
I received input date as string (“02/04/2023”)
specifically I need to manage difference from config file asset. there type will be Text with value =1
pikorpa
(Piotr Kołakowski)
2
hey @ch460960
try to use:
inputDate = DateTime.ParseExact(yourInputDateString, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)
dateDifference (TimeSpan) = DateTime.Now - inputDate
If dateDifference.TotalDays > CInt(configDaysDifference) Then "The difference is greater than 1 day."
mkankatala
(Mahesh Kankatala)
3
Hi @ch460960
Follow the below steps -
- Assign -> InputDate [String Datatype] = "02/04/2023"
The below syntax is to get the difference between current date (Today Date) and Input Date
- Assign -> DifferenceofDate [System.Double Datatype] = DateTime.ParseExact(Now.ToString("MM/dd/yyyy"),"MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture).Subtract(DateTime.ParseExact(InputDate,"MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)).TotalDays
Take an If activity to check the condition -
- Condition -> DifferenceofDate > Cdbl(Config("Asset Name"))
In then block insert log message activity to print the log message in the output panel.
Check the below workflow for better understanding,
Hope it helps!!
@ch460960
you can use this
inputstr=“02/04/2023”
CInt(DateDiff(DateInterval.Day,datetime.ParseExact(inputstr,"MM/dd/yyyy",system.Globalization.CultureInfo.InvariantCulture),cdate(now.ToShortDateString)))