−
In this chapter we will look at the Visual Basic data type. In addition to providing a place to store a date, many tasks can be performed on a Date variable, such as adding or subtracting time, comparing dates and obtaining the System date and time. Each of these topics areas will be covered in detail in this chapter.
+
In this chapter we will look at the Visual Basic ''Date'' type. In addition to providing a place to store a date, many tasks can be performed on a Date variable, such as adding or subtracting time, comparing dates and obtaining the System date and time. Each of these topics areas will be covered in detail in this chapter.
    
== Creating and Initializing a Visual Basic Date ==
 
== Creating and Initializing a Visual Basic Date ==
 
</pre>
 
</pre>
   −
The Date value is initialized using a date string in the from mm/dd/yyyy encapsulated in hash (#) characters. For example to set the date to August 2, 2007:
+
The Date value is initialized using a date string in the form ''mm/dd/yyyy'' encapsulated in hash (#) characters. For example to set the date to August 2, 2007:
    
<pre>
 
<pre>
 
'''DateAdd(''' ''interval'', ''number'', ''date'') As Date
 
'''DateAdd(''' ''interval'', ''number'', ''date'') As Date
   −
The interval parameter specifies the unit of time to be added or suibtracted (such as day, year, hour, minute etc). The allowable values for this parameter are as follows:
+
The interval parameter specifies the unit of time to be added or subtracted (such as day, year, hour, minute etc). The allowable values for this parameter are as follows:
    
<google>ADSDAQBOX_FLOW</google>
 
<google>ADSDAQBOX_FLOW</google>
 
== Retrieving Parts of a Date or Time ==
 
== Retrieving Parts of a Date or Time ==
   −
The interval types listed in the ''DateAdd()'' section abovbe can be used with the Visual Basic ''DatePart()'' function to extract parts of a date or time. The syntax for the ''DatePart()'' function is as follows:
+
The interval types listed in the ''DateAdd()'' section above can be used with the Visual Basic ''DatePart()'' function to extract parts of a date or time. The syntax for the ''DatePart()'' function is as follows:
    
'''DatePart(''' ''interval'', date) As Integer
 
'''DatePart(''' ''interval'', date) As Integer
 
== Finding the Interval Between Two Dates or Times ==
 
== Finding the Interval Between Two Dates or Times ==
   −
The difference between to dates or times can be determined using the Visual Basic ''DateDiff()'' function, the syntax for which is:
+
The difference between two dates or times can be determined using the Visual Basic ''DateDiff()'' function, the syntax for which is:
    
'''DateDiff(''' ''interval'', ''Date1'', ''Date2'' ''')'''
 
'''DateDiff(''' ''interval'', ''Date1'', ''Date2'' ''')'''
   −
The ''interval'' parameter specifies the unit of time to use when measuring the difference between two date and using the same values as those outlined for the ''DateAdd()'' function covered previously in this chapter. The two date values the represent the dates to compared. The function returns the difference as the number of specified units. For example, if the interval is defined as ''DateInterval.Day'' and the two dates are a week apart, ''DateDiff()'' will return 7.
+
The ''interval'' parameter specifies the unit of time to use when measuring the difference between two date and using the same values as those outlined for the ''DateAdd()'' function covered previously in this chapter. The two date values represent the dates to compared. The function returns the difference as the number of specified units. For example, if the interval is defined as ''DateInterval.Day'' and the two dates are a week apart, ''DateDiff()'' will return 7.
    
The following examples demonstrate possible uses of the ''DateDiff()'' function:
 
The following examples demonstrate possible uses of the ''DateDiff()'' function:
 
== Accessing the System Date and Time from Visual Basic ==
 
== Accessing the System Date and Time from Visual Basic ==
   Exception encountered, of type "Error"
[c7ff67b9] /index.php?diff=prev&oldid=7220&title=Working_with_Dates_and_Times_in_Visual_Basic Error from line 434 of /var/www/techotopia/includes/diff/DairikiDiff.php: Call to undefined function each()
Backtrace:
#0 /var/www/techotopia/includes/diff/DairikiDiff.php(544): DiffEngine->diag()
#1 /var/www/techotopia/includes/diff/DairikiDiff.php(344): DiffEngine->compareSeq()
#2 /var/www/techotopia/includes/diff/DairikiDiff.php(227): DiffEngine->diffLocal()
#3 /var/www/techotopia/includes/diff/DairikiDiff.php(721): DiffEngine->diff()
#4 /var/www/techotopia/includes/diff/DairikiDiff.php(859): Diff->__construct()
#5 /var/www/techotopia/includes/diff/DairikiDiff.php(980): MappedDiff->__construct()
#6 /var/www/techotopia/includes/diff/TableDiffFormatter.php(194): WordLevelDiff->__construct()
#7 /var/www/techotopia/includes/diff/DiffFormatter.php(140): TableDiffFormatter->changed()
#8 /var/www/techotopia/includes/diff/DiffFormatter.php(82): DiffFormatter->block()
#9 /var/www/techotopia/includes/diff/DifferenceEngine.php(881): DiffFormatter->format()
#10 /var/www/techotopia/includes/diff/DifferenceEngine.php(797): DifferenceEngine->generateTextDiffBody()
#11 /var/www/techotopia/includes/diff/DifferenceEngine.php(728): DifferenceEngine->generateContentDiffBody()
#12 /var/www/techotopia/includes/diff/DifferenceEngine.php(662): DifferenceEngine->getDiffBody()
#13 /var/www/techotopia/includes/diff/DifferenceEngine.php(632): DifferenceEngine->getDiff()
#14 /var/www/techotopia/includes/diff/DifferenceEngine.php(453): DifferenceEngine->showDiff()
#15 /var/www/techotopia/includes/page/Article.php(797): DifferenceEngine->showDiffPage()
#16 /var/www/techotopia/includes/page/Article.php(508): Article->showDiffPage()
#17 /var/www/techotopia/includes/actions/ViewAction.php(44): Article->view()
#18 /var/www/techotopia/includes/MediaWiki.php(490): ViewAction->show()
#19 /var/www/techotopia/includes/MediaWiki.php(287): MediaWiki->performAction()
#20 /var/www/techotopia/includes/MediaWiki.php(714): MediaWiki->performRequest()
#21 /var/www/techotopia/includes/MediaWiki.php(508): MediaWiki->main()
#22 /var/www/techotopia/index.php(41): MediaWiki->run()
#23 {main}