I have two date from training start and finish time. Example the training start time: 17.01.2010 and finish time 03.02.2010. When I select january in my list I want to showi I attend in this month 13 days and if i select fabruary I will attend this tarining
3 day. I hope, I will explain my problem
You should to be able to make use of DateTime.DaysInMonth() to get the total number of days in a month, then subtract that from your actual day of your date. Good luck!
Do you mean, if you select January, you will be informed that you have training on the 17th of January and if you choose February, you will be informed that you will have training on the 3rd?
or
You want to calculate the days between those two dates (January 17 up to Feb 1)?
DateTime dtTo, dtFrom;
dtTo = Convert.ToDateTime(<Ending date>);
dtFrom = Convert.ToDateTime(<starting date>);
// write switch case statement .for January the following code might work.
DateTime dtJan = Convert.ToDateTime("01/31/2010");
if (dtJan > dtFrom)
{
dtTo = dtJan;
}
if (dtJan < dtTo)
{
dtFrom = dtJan;
}
TimeSpan diff1 = dtTo.Subtract(dtFrom);
add 1 day to the diff1 for calculating exact number of days of training. if you select Jan for the training start date 17.01.2010, ther difference between 17.01.2010 and 31.01.2010 is 14 i.e. excluding day 17, so you need to add one more day. so the actual
number of days will be 15.
Member
129 Points
242 Posts
day calculate
Mar 23, 2010 11:48 AM|Ozo|LINK
I have start and finish time. For exampe; start time is 15.01.2010 anf finish time 03.02.2010. I want to day on the month. For example;
If I select january I wantto calculate 15 days , If I select fabruary I want to calculate 3days.
Member
20 Points
4 Posts
Re: day calculate
Mar 23, 2010 02:42 PM|JeromeP|LINK
It might be me, but your post made no sense.
Could you try to describe more what you're tying to do ? What is you "select" march, what do you want to get ?
Member
129 Points
242 Posts
Re: day calculate
Mar 23, 2010 04:04 PM|Ozo|LINK
I have two date from training start and finish time. Example the training start time: 17.01.2010 and finish time 03.02.2010. When I select january in my list I want to showi I attend in this month 13 days and if i select fabruary I will attend this tarining 3 day. I hope, I will explain my problem
All-Star
101931 Points
20703 Posts
Re: day calculate
Mar 23, 2010 04:11 PM|MetalAsp.Net|LINK
You should to be able to make use of DateTime.DaysInMonth() to get the total number of days in a month, then subtract that from your actual day of your date. Good luck!
Member
33 Points
20 Posts
Re: day calculate
Mar 25, 2010 09:57 AM|venkata kishore|LINK
u want to exclude saturday, sunday or u want to include both ?
Star
10444 Points
2463 Posts
Re: day calculate
Apr 20, 2010 11:14 AM|sirdneo|LINK
This query will give you a good start
select last_day(start_date)-start_date days_of_jan from (select
to_date('15.01.2010', 'dd.mm.yyyy') start_date,
to_date('03.02.2010', 'dd.mm.yyyy') end_date
from dual)
Zeeshan Umar
~Please Mark As Answer, one or multiple posts, which helped you. So that it might be useful for others~
Member
2 Points
10 Posts
Re: day calculate
Apr 21, 2010 05:01 AM|noelablon|LINK
don't get the question too.
Do you mean, if you select January, you will be informed that you have training on the 17th of January and if you choose February, you will be informed that you will have training on the 3rd?
or
You want to calculate the days between those two dates (January 17 up to Feb 1)?
Member
377 Points
140 Posts
Re: day calculate
May 04, 2010 06:05 AM|Ravihimanshu|LINK
add 1 day to the diff1 for calculating exact number of days of training. if you select Jan for the training start date 17.01.2010, ther difference between 17.01.2010 and 31.01.2010 is 14 i.e. excluding day 17, so you need to add one more day. so the actual number of days will be 15.
hope this will help you.