.net - Calculate A New Date Simply By Using The Build-in Dateadd Function?
Oct 14, 2009
I would like to calculate a new date simply by using the build-in dateadd function, but take into account that only weekdays should be counted (or 'business days' so to speak).I have come up with this simple algorithm, which does not bother about holidays and such. I have tested this with some simple dates, but would like some input if this can be done in better ways.This sample assumes a week with 5 business days, monday-friday, where first day of the week is monday. Dateformatting used here is d-m-yyyy, the sample calculates with a startdate of october 1, 2009.
Here is the simple form:
Dim d_StartDate As DateTime = "1-10-2009"
Dim i_NumberOfDays As Integer = 12
Dim i_CalculateNumberOfDays As Integer
[code]....
View 3 Replies
ADVERTISEMENT
Sep 16, 2010
I am trying to compute time off, I have a datetimepicker which allow user to select a day he wishes to start leave and a textbox to specify no of days applying for.Now I wand to use dateadd function to calculate resumption date excluding Weekends.
View 2 Replies
Jul 13, 2009
Does VB9 provide a compile-time date/time stamp function? I know VB6 did not; I'm hoping VB9 does.
View 1 Replies
Feb 22, 2011
If DateDiff(DateInterval.Day, moDoBooking.m_CurrentDay, moDoBooking.m_BaseDay) _
> DateDiff(DateInterval.Day, DateAdd(DateInterval.Day, _
Convert.ToDouble(moDoBooking.oBooking.oFacility.ADAYS), moDoBooking.m_BaseDay), _
moDoBooking.m_BaseDay) Then
This condition won't satisfy with these values:
moDobooking.m_CurrentDay = 2/3/2011
moDobooking.m_BaseDay = 22/02/2011
moDoBooking.oBooking.oFacility.ADAYS = 1
You might say this is dead-easy but honestly it's late here and my head is not working at all! Could AnyOne tell me why is that?
View 2 Replies
Jun 15, 2010
I am using the following code to add some value to a date:
Dim strdate As Date
Dim numinterval As Double
numinterval = 149548.720386359
strdate = DateAdd(DateInterval.day, numinterval, #1/1/1601#)
MsgBox(strdate)
The value numinterval is the number of days passed since 1/1/1601 (this is how date is counted for things like 'last logon time', 'last bad password' in Active directory). I do some calculation and get that numinterval value in days.. But since I want it to return the time more accurately, I tried first multiplying numinterval by 1400 for number of minutes.. And I changed the interval as dateinterval.minute... That worked fine!
But, when I tried again by multiplying it further by 60, to get the time accurately in seconds and changed the interval to dateinterval.second it throws the following exception:
Arithmetic operation resulted in an overflow
I changed the type of numinterval into long, but the same problem..
View 2 Replies
May 9, 2010
i need to make a program that simply takes current date and the input date (users birth date) from the user both as i integer then if the users is 18 or more then the back color turns green otherwise turns red.
Code:
Public Class Form1
Dim int_ThisDay, int_BirthDay, int_ThisMonth, int_BirthMonth, int_ThisYear, int_BirthYear, int_DifYear, int_DifMonth, int_DifDay As Integer
[Code]....
View 3 Replies
Mar 30, 2009
I am trying to calculate the number of years for my calculate age event handler, however i am apparently missing a method or whatnot because im trying to calculate the age , can anyone suggest help on this. I need to subtract years to get my age but when i try the birthdate.Subtract (currentDate) method i get an error about not able to convert from LONG?
So below is what I have.
Private Sub btnCalculateAge_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculateAge.Click
Dim currentDate As Date
Dim BirthDate As Date
Dim Age As Long
[CODE]
View 7 Replies
Jun 25, 2009
there, im doing a leave management system with vb 2005..and here's my problem -how do i 'find' the expiry date?? eg: from the datetimepicker in my form, if the date i select is 1st january 2009.....how do i type the code to find the expiry date 1 year later (which is 1st january 2010) and display the date in a textbox in my form???
View 1 Replies
Aug 28, 2011
Is there a query that can use to sum up data from date until another date? how to do it in VB.NET.
View 1 Replies
Nov 18, 2009
I need to add 3 months to a date so i can calculate when a clients email bundle is out dated.so for instance the client registed his bundle on 2009/09/01. I need to be able to add 3 months to this date so it comes out with 2009/12/01 and then compare the dates.
View 1 Replies
Dec 31, 2011
Can someone please help me make this work? I want to do in vb.net calculate time between to date like this:
startdate: 2011/12/30
enddate: 2011/12/31
Calculate: ? hour ? minute ? secends
View 2 Replies
Nov 23, 2009
how to calculate a weekday of a given date?
View 8 Replies
May 15, 2010
I have a two maskedtextbox, one textbox named as masktxtdepostdate and , masktxtmaturitydate, txtnoofmonth.
i changed maskedtextbox property as date, in format "YYYY-MM-DD";
now i need to calculate masktxtmaturitydate after entering the values in, masktxtdepostdate and txtnoofmonth.[code]...
View 2 Replies
May 31, 2011
I'd like do make a program which returns you how old you are, in years, months, weeks and days. But I didn't get it to compare different times. Input is a string which looks like 01.01.2011 (dd.mm.yyyy).
My code so far is this:
Try
dim date1 as string = '01.01.2011'
' Today
Dim date2 As Date
date2 = Date.Now
' number of seconds since date1
[Code] .....
View 1 Replies
Jun 10, 2010
write a code that can calculate the difference between the datetime a article has been published and datetime of now.like this example :this article has been published 4 minutes ago...this article has been published about 2 days ago...
View 2 Replies
Jun 3, 2010
Dim myRequest As System.Net.WebRequest = System.Net.WebRequest.Create(url)
Dim myResponse As System.Net.WebResponse = myRequest.GetResponse()
Dim rssStream As System.IO.Stream = myResponse.GetResponseStream()
Dim rssDoc As New System.Xml.XmlDocument()
Try
rssDoc.Load(rssStream)
[Code]...
Folks this is what I'm using to parse an RSS feed for the last updated time. Is there a quicker way? Speed seems to be a bit slow on it as it pulls down the entire feed before parsing.
View 1 Replies
Nov 21, 2011
I need a function that would return true if the date provided was a payday or date of next few weeks paydays.Paydays are every 14 days on a Friday (not twice a month).I tried several attempts, but don't have a clue where to start, except that the function needs a reference date to calculate from. [code]
View 16 Replies
Sep 15, 2009
I am using VB.NET. Is there a date function that calculates the date based on the number of months I have given?
for example, if i say July 2009 and looking for 10 months back, it should return Sept 2008.
View 4 Replies
Apr 18, 2011
Example of a function that would return an integer (how many months old) based on a persons age when given the date of birth?
View 1 Replies
Feb 15, 2012
I need to calculate date difference using flowing query but it does not work. [code]...
View 3 Replies
Feb 27, 2012
Im a beginner at visual basic. I did some codes refering to a form in which I need to calculate the differences between my my date of birth to another date. I did a statement which gives me the difference between those in the format of years, but I need to know how I can put the months and days example if my birthdate is 11/26/1991 and I want to calculte how many years, month and days has transcurred until today it would be like 20 years 3 months and 11 days.
[Code]...
View 17 Replies
Feb 11, 2012
[Code]...
how could i make my datetimepicker to compute for the expiry date within 5 years... example date grated is 1/2/2012 and expires on 1/2/2016
View 1 Replies
May 5, 2011
I am developing c#.net solution where i have to calculate Start Date based on provided End date and Duration (back days) without weekends.
i.e. End Date: 05/5/2011
Back days: 5
Start Date = (05/5/2011) - 5 days (Excludes weekends)
Start Date = 29/04/2011
View 3 Replies
May 16, 2009
Is it possible to calculate the currently selected date in a month calculator?I need to be able to produce a number between 1 and 5 for the currently selected week.
View 2 Replies
Feb 11, 2012
I'm trying to get an If statement to check is the date picked from a datetimepicker is at least 3 days prior to the current date, I can get it to calculate the difference however if I chose a date that 4 days prior to the current date (i.e the result being -4), the else statement doesnt fire.is this something to do with the result being a negative value? I did try to assign the DateDiff result to a variable defined as a short and then used this variable in the If statement, but still get the same issue. Option Strict isn't showing any issues.
[Code]...
View 2 Replies
Oct 15, 2009
I'm using VB.NET in Visual Studio 2008. I'm programming an application to take processing orders and give the total price plus the shipping date. I would like something like : shipping_date = Current_Date + 3 days but I know this doesn't work. Any ideas?
View 1 Replies
May 10, 2011
I am trying to build a date calculator utility (DateCalc). It returns the number of days,weeks, months etc between two dates.I worked hard and long trying to find out how to convert a date into a format on which you can perform math operations (for the "what's the date in 'n' days time" part) and it works! I can also use the minus operator to find out previous dates, from say 10000 days ago... BUT...I want to develop it further, and this is where I need help (i am still very newbie remember)Can you help me to find a way to code this bit to ignore weekends and saturdays or sundays individually, and a range of dates in its calculation? I have two datetime pickers and a some checkboxes.DTPickFromDTPickToChkBoxExWeekendChkBoxEXSaturdaysChkBoxExSundays An image of my form and it's components is here :--> [URL] Also, as part of my 'Datecalc', I'd like to find the dates of every other saturday and sunday in the future.
View 9 Replies
Sep 23, 2011
Calculate the value between 0 & 180 degrees that makes the function sinx=x
View 6 Replies
Apr 26, 2010
I want to calculate the time taken to execute a function.[code]...
View 6 Replies
Apr 28, 2011
I'm trying to write a program that allows the user to enter 10 numbers into an input box and then the program will use a function to calculate the average of those numbers. I'm really illiterate when it comes to Visual Basic.
View 2 Replies