Hi,
I am reading a cell 31/03/2023 which is a date and variable type is generic value. I wan to use a if condition to do a validation where the cell date should be equal or more than 01/04/2023 which executes the then or otherwise the else. How do i script this?
To add on the cell date it reads can be dd/Mm/yyyy or d/m/yyyy.
mkankatala
(Mahesh Kankatala)
April 2, 2024, 10:37am
3
Hi @mark_rajkumar1
Store the Cell value in a variable called InputValue.
You can give the below expression in If condition to check the condition,
- Condition -> DateTime.ParseExact(InputValue.ToString, {"dd/MM/yyyy","d/M/yyyy"}, System.Globalization.CultureInfo.InvariantCulture, Datetimestyles.None) >= DateTime.ParseExact("01/04/2023", "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture)
It will wok weather the cell value is in these formats, dd/MM/yyyy and dd/M/yyyy
Hope it helps!!
Hi @mkankatala , as for 01/04/2023 which i want it be current period. In another words, i wan the script to compare dates with today date.
mkankatala
(Mahesh Kankatala)
April 2, 2024, 11:14am
5
Okay got it… @mark_rajkumar1
Then use the below condition,
- Condition -> DateTime.ParseExact(Input.ToString, {"dd/MM/yyyy","dd/M/yyyy"}, System.Globalization.CultureInfo.InvariantCulture, Datetimestyles.None) >= DateTime.Now
Hope it helps!!
Hi @mkankatala i wan to set the date as 01-04 fixed and the years shld be moving forward.
@mkankatala for example if cell date is 31/03 2024 and is not greater than 01/04/2024, it will execute else
mkankatala
(Mahesh Kankatala)
April 2, 2024, 11:51am
8
Could you be more specific. What is your requirement… @mark_rajkumar1
My requirement is i need read cell what contains a date but variable type is generic value. However i want to use that variable to see is it greater than 01/04 which current date and year. If it is greater it had to do this validation or else no validation. If next year or even following year the script should know carry on with the validation with the current period.
@Anil_G any inputs to this
Anil_G
(Anil Gorthi)
April 2, 2024, 3:14pm
11
@mark_rajkumar1
Give condition like this
Cdate(GenericValue.Tostring)> Cdate("01/04/" + Now.Year.ToString)
Cheers
mkankatala
(Mahesh Kankatala)
April 2, 2024, 3:34pm
12
Okay @mark_rajkumar1
I modified the condition based on your requirement, check the below one,
- Condition -> DateTime.ParseExact(Input.ToString, {"dd/MM/yyyy","dd/M/yyyy"}, System.Globalization.CultureInfo.InvariantCulture, Datetimestyles.None) >= DateTime.ParseExact("01/04/"+Now.tostring("yyyy"), "dd/MM/yyyy", System.globalization.Cultureinfo.Invariantculture)
Hope it helps!!
@Anil_G i dont wan the time to be shown. The date format has to be shown as dd/Mm/yyyy or d /m/yyyy
Anil_G
(Anil Gorthi)
April 2, 2024, 6:03pm
14
@mark_rajkumar1
For comparing in the current date I am not using time and in the generic value I believe you are not getting it
cheers
system
(system)
Closed
April 5, 2024, 6:03pm
15
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.