vaishali
(vaishali)
January 27, 2022, 6:41am
1
Hi All,
I have a input as 11/02/2019 which is 11 th month 02 date.
I need to get the output as 11/01/2020
I have to get the output as same month but 1 date before from the output.
If adddays 365 for some time I am not getting the expected output…
Thanks
example :
DateTime.Now.Add(-3).ToString(“dd-MM-yy”)
use.Add(-1) to get todays date minus 1
as @fayis.cm example using → .addDays(-1) will give diffrent result format
please refer to this
Hi Everyone,
I am trying to subtract 3 days from the current system date. from the below syntax,
datetime.Now.ToString(“dd-MM-yy”)
Can anyone advice how to solve this and may I know can I use that syntax in the
“=IF(ISNA(VLOOKUP(A2,‘18-01-19’!A:D,1,FALSE)),”“New Deal”“,”“Old Deal”“)”
Instead of hardcoding date in the vlookup formula can I use dynamic value ?
Thank you very much in advance
Regards
Vishnu
regards
ahmad
1 Like
fayis.cm
(Fayis Cm)
January 27, 2022, 6:51am
3
Try This:
Convert.ToDateTime(“11/02/2019”).AddDays(-1).AddYears(1).ToShortDateString
Gokul001
(Gokul Balaji)
January 27, 2022, 6:59am
4
Hi @vaishali
Try the below expression
DateTime.ParseExact("11/02/2019",("dd/MM/yyyy"),Globalization.CultureInfo.InvariantCulture).AddMonths(-1).AddYears(1).ToString("dd/MM/yyyy")
Have a view on the link for more information
Hope it will help you.
Regards
Gokul
vaishali
(vaishali)
January 27, 2022, 7:25am
6
Hi,
Instead of adding addyear (1)
Need to pass current t year
Addyear(1)
Shall we pass datetime.now.year?
Gokul001
(Gokul Balaji)
January 27, 2022, 7:42am
7
Hi @vaishali
Try this below expression
System.Text.RegularExpressions.Regex.Replace(DateTime.ParseExact("11/02/2019",("dd/MM/yyyy"),Globalization.CultureInfo.InvariantCulture).AddMonths(-1).ToString("dd/MM/yyyy"),"\d{4}",DateTime.Now.Year.ToString)
Hope it will work
If it is work mark the appropriate post as solved. it will help for other user
Regards
Gokul
fayis.cm
(Fayis Cm)
January 27, 2022, 7:44am
8
Hi,
The DateTime.AddYears() method used to add the specified number of years to the value of this instance. we can only pass integer values , which will increment years from the current year.
if you want to subtract years, then use a negative value.
Thank you.
Gokul001
(Gokul Balaji)
January 27, 2022, 7:58am
9
You can see the result you need @vaishali
Regards
Gokul
system
(system)
Closed
January 30, 2022, 7:59am
10
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.