SauravYadav
(Saurav Yadav)
November 27, 2019, 12:36pm
1
Hi,
I want previous month date when am in 1st week of current month as stated below,
Ex- If date is 02-12-2019 then I need date 30-11-2019
If date is 02-03-2020 then I need date 28-11-2019
My intention is to get previous saturday date if am runnig the process on monday.
Regards,
Saurav
sarathi125
(Parthasarathi)
November 27, 2019, 12:45pm
2
@SauravYadav ,
The below line will give you previous month Last day,
New DateTime(Convert.ToDateTime("11-28-2019").AddMonths(-1).Year, Convert.ToDateTime("11-28-2019").AddMonths(-1).Month, (DateTime.DaysInMonth(Convert.ToDateTime("11-28-2019").AddMonths(-1).Year, Convert.ToDateTime("11-28-2019").AddMonths(-1).Month))).ToString
Hi,
Actaully, the example is as below, in query I have mentioned wrongly.
Ex- If date is 02-12-2019 then I need date 30-11-2019
If date is 02-03-2020 then I need date 28-02-2020
But anyways I have taken another approach by subtracting -2 from current date and it will give me saturday date as below,
DateTime.Now.Adddays(-2).ToString(“dd”, System.Globalization.CultureInfo.InvariantCulture)
Regards,
Saurav
system
(system)
Closed
November 30, 2019, 3:31pm
4
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.