In this chapter we will look at the Visual Basic data ''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 ==
</pre>
The Date value is initialized using a date string in the from form ''mm/dd/yyyy '' encapsulated in hash (#) characters. For example to set the date to August 2, 2007:
<pre>
'''DateAdd(''' ''interval'', ''number'', ''date'') As Date
The interval parameter specifies the unit of time to be added or suibtracted subtracted (such as day, year, hour, minute etc). The allowable values for this parameter are as follows:
<google>ADSDAQBOX_FLOW</google>
== Retrieving Parts of a Date or Time ==
The interval types listed in the ''DateAdd()'' section abovbe 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
== Finding the Interval Between Two Dates or Times ==
The difference between to two dates or times can be determined using the Visual Basic ''DateDiff()'' function, the syntax for which is:
'''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 following examples demonstrate possible uses of the ''DateDiff()'' function:
== Accessing the System Date and Time from Visual Basic ==
Exception encountered, of type "Error"
[82c20b9a] /index.php/Special:MobileDiff/7220 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/extensions/MobileFrontend/includes/diff/InlineDiffFormatter.php(99): WordLevelDiff->__construct()
#7 /var/www/techotopia/includes/diff/DiffFormatter.php(140): InlineDiffFormatter->changed()
#8 /var/www/techotopia/includes/diff/DiffFormatter.php(82): DiffFormatter->block()
#9 /var/www/techotopia/extensions/MobileFrontend/includes/diff/InlineDifferenceEngine.php(117): DiffFormatter->format()
#10 /var/www/techotopia/includes/diff/DifferenceEngine.php(797): InlineDifferenceEngine->generateTextDiffBody()
#11 /var/www/techotopia/includes/diff/DifferenceEngine.php(728): DifferenceEngine->generateContentDiffBody()
#12 /var/www/techotopia/extensions/MobileFrontend/includes/specials/SpecialMobileDiff.php(241): DifferenceEngine->getDiffBody()
#13 /var/www/techotopia/extensions/MobileFrontend/includes/specials/SpecialMobileDiff.php(135): SpecialMobileDiff->showDiff()
#14 /var/www/techotopia/extensions/MobileFrontend/includes/specials/MobileSpecialPage.php(53): SpecialMobileDiff->executeWhenAvailable()
#15 /var/www/techotopia/includes/specialpage/SpecialPage.php(384): MobileSpecialPage->execute()
#16 /var/www/techotopia/includes/specialpage/SpecialPageFactory.php(553): SpecialPage->run()
#17 /var/www/techotopia/includes/MediaWiki.php(281): SpecialPageFactory::executePath()
#18 /var/www/techotopia/includes/MediaWiki.php(714): MediaWiki->performRequest()
#19 /var/www/techotopia/includes/MediaWiki.php(508): MediaWiki->main()
#20 /var/www/techotopia/index.php(41): MediaWiki->run()
#21 {main}