1
Answer

Date TIme

Photo of Selvaraj

Selvaraj

14y
1.9k
1

The requirement is if Filedropdate < 14 then I hav to have fileactivedatetime as that mothfirstday else next month first date.ie
if Filedropdate = 12/7/2010 ( as day is less than 14 ) then fileactivedatetime  should be 01/7/2010
if Filedropdate = 17/7/2010 ( as day is greater than 14 ) then fileactivedatetime should be 01/8/2010
Please provide a solution.

Answers (1)

0
Photo of Hirendra Sisodiya
NA 8.8k 3m 14y

Hello Selvaraj
Try this code:
int
TempDate = Filedropdate.Day;
int TempMonth = Filedropdate.Month;
int Tempyear = Filedropdate.Year;
if (TempDate < 14)
{
Filedropdate =
new DateTime(Tempyear, TempMonth, 1);
}
else
{
if (TempMonth == 12)
{
Filedropdate =
new DateTime(Tempyear+1, 1, 1);
}
else
{
Filedropdate =
new DateTime(Tempyear, TempMonth + 1, 1);
}

}
 
thanks
 
Please mark as answer if it helps