how to get the number of months and exceed days - asp.net

here is my sample is this correct?
number of months=nms
days=30 days only
sample: nms=30 days count from the date hired
is this correct?

If you want to get exact month between two date. You have to get difference of them. You can use DateDiff function in Dot Net.

Related

Quantmod R , how to select cells with Sys.date?

I'm making some calculations based on quantmod for some stocks.
Below I prepared a very simple example to reflect what I'd like to do which is at this time select some cells based on date, for example yesterday.
library(quantmod)
getSymbols("BAC", from="2018-06-18", src="yahoo")
As a result I get the following:
Now I'd like to make some calculations with the volume of yesterday so I wonder if something like this could work:
# I would like to multiply yesterday's volume for 1.05.
Vol_k <- (BAC$BAC.Volume Sys.Date()-1) * 1.05
How do I use sys.date here to indicate today -1 and select the volume cell of yesterday date?
Thank you very much for any comment.
V.
When I pulled this data, I don't get anything for yesterday being the 4th July (timezone I assume, or maybe due to public holiday in US?) so I did it for 2 days ago.
BAC[Sys.Date() - 2, "BAC.Volume"]
should give you the desired result of the volume. Did a bit of research (https://s3.amazonaws.com/assets.datacamp.com/blog_assets/xts_Cheat_Sheet_R.pdf)
last(BAC, '1 day')$BAC.Volume
should give you the last day, regardless of weekends/ holidays
You can always get the last value by accessing the index.i.e.
xts.object[max(index(xts.object),column]
In your case:
BAC[max(index(BAC)),"BAC.Volume"]

How to make a Line Chart with multiple Series where one series has null values

I have a line chart that has 3 series - the first shows cumulative sales for last week - the next shows the daily sales for this week and the next shows cumulative sales for this week.
This shows the days of the week at the bottom.
Last weeks cumulative sales show fine as there is data for each day of the week.
For this week's daily and cumulative sales I don't want a point drawn if the day hasn't happened yet.
I loop through the days of the week and if the day hasn't happened yet I want to assign the value to null instead of 0 and I don't want the line to show anything for these series if the day hasn't happened yet.
Does anyone have advice on this point?
After much looking I found how to do this. It was very easy and described in the below documentation from shieldui.com:
Example using null in dataSeries
I had earlier tried all manner of sending empty strings, null value strings and in the end it was as simple as setting that data member to null like this and shieldui handled it correctly:
dailyincome = null;

Is 23:59:59.999 end of day?

In my project involving dates calculation I am wondering what is really end of day coming from a previous question:
extract date ranges grouped by day from time intervals
Is 23:59:59:999 end of day or is it 24:00:00:000?
Thanks.
In .Net the property Hour is between 0 to 23 so I think 23:59:59:999 is the correct answer

VB or macro to exclude period of times from time duration calculation in Excel

I have an Excel table which contains thousands of incident tickets. Each tickets typically carried over few hours or few days, and I usually calculate the total duration by substracting opening date and time from closing date and time.
However I would like to take into account and not count the out of office hours (night time), week-ends and holidays.
I have therefore created two additional reference tables, one which contains the non-working hours (eg everyday after 7pm until 7am in the morning, saturday and sunday all day, and list of public holidays).
Now I need to find some sort of VB macro that would automatically calculate each ticket "real duration" by removing from the total ticket time any time that would fall under that list.
I had a look around this website and other forums, however I could not find what I am looking for. If someone can help me achieve this, I would be extremely grateful.
Best regards,
Alex
You can use the NETWORKDAYS function to calculate the number of working days in the interval. Actually you seem to be perfectly set up for it: it takes start date, end date and a pointer to a range of holidays. By default it counts all days non-weekend.
For calculating the intraday time, you will need some additional magic. assuming that tickets are only opened and closed in bussines hours, it would look like this:
first_day_hrs := dayend - ticketstart
last_day_hrs := ticketend - daystart
inbeetween_hrs := (NETWORKDAYS(ticketstart, ticketend, rng_holidays) - 2) * (dayend - daystart)
total_hrs := first_day_hrs + inbetween_hrs + last_day_hrs
Of course the names should in reality refer to Excel cells. I recommend using lists and/or names.

Interval of one month back not working on the 31st?

Essentially, I have a query that is responsible for fetching all records (with specific filters) within the last month. I'm using Oracle's interval keyword and all was working great until today (December 31st, 2009). The code I'm using is
select (sysdate - interval '1' month) from dual
and the error I get it
ORA-01839: date not valid for month specified
How can I use the interval keyword to be compatible with any date? Or if anyone has a better way of approaching the issue, I'm all ears.
Thank you.
try
select add_months(sysdate,-1) from dual
Being pedantic...
The requirements are not quite specified perfectly unambiguously. What does the business mean by "within the last month"? Most people would take that to mean "within the current calendar month" in which case I'd use:
TRUNC(SYSDATE,'MM')
Otherwise, perhaps they want an arbitrary period of 1 month prior to the current date - but then how do you define that? As you've found, INTERVAL '1' MONTH simply subtracts one from the month portion of the date - e.g. 15-JAN-2009 - INTERVAL '1' MONTH returns 15-DEC-1999. For some dates, this results in an invalid date because not all months have the same number of days.
ADD_MONTHS resolves this by returning the last day in the month, e.g. ADD_MONTHS(31-DEC-2009,-1) returns 30-NOV-2009.
Another possibility is that the business actually wants to use an average month period - e.g. 365/12 which is approximately 30.4. They might want you to use SYSDATE-30, although of course twelve iterations of this will only cover 360 days of the year.

Resources