Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Suppose I have Month august and divide it in 2 slot i.e 1-15 ,16-31

Then if the current date is coming in between of any these slot the I should get the start date and end of previous 15 days.
1.e current date is 20 august 2010 the the start date will be 1 august 2010 and end date will be 15 aug 2010

and if current date is 10 aug 2010 the the start date I should get will 16 july 2010 and end date will be 31 july 2010 according to the month containing days
Posted
Updated 8-Jul-20 22:43pm

Your question makes no sense, how does 10 Aug get you a range in July ? Apart from that, it has nothing to do with ASP.NET, it's a basic VB question, you can use the < and > operators on the date class to work it out. Or just check the day and see if it's < 16, if it's not, it's in the second slot. This is really basic programming, are you really doing ASP.NET ? I think you need to buy a basic VB book and read it.
 
Share this answer
 
Sound like you are working on some Timesheet kinda application. All you need is DateTime manipulations. As, I just shared with you, try it using these properties[^].

If you face issues, post the code you tried with the issue.
 
Share this answer
 
Hi Niraj,
If you are loooking for SQL then you can check this tutorial.

http://shivasoft.in/blog/sql/get-the-fortnight-start-and-end-date-sql-server/[^]

And in case of C# or VB you can simply use logical operators.
If you want exact code then reply to this thread, I will try to help you.

Regards,
Jitendra Zaa
 
Share this answer
 
DateTime ct = DateTime.Now;
var EndDate = ct.AddDays(-(ct.Day % 16 + ct.Day / 16));
var startdate = new DateTime(EndDate.Year, EndDate.Month, dt.Day < 16 ? 15 : 1);

C#

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900