Tecnologia, programação e muito Visual FoxPro.

sexta-feira, 29 de maio de 2009

Re: [Access VBA Central] how to calculate between two dates



Note to using the following all you need to is turn your individual date items into a single string and make the date1 and then using the Now( ) function as date2. 
 
VBA DateDiff Function
 
The VB DateDiff function returns a variant variable result of subtracting two dates.  The unit of measure is defined in the interval argument. 
Syntax

DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])
 
Arguments:
 
interval - Required. String expression that is the interval of time you use to calculate the difference between date1 and date2. See a list of valid intervals in the DateAdd function above.

date1, date2 - Required; Variant (Date). Two dates you want to use in the calculation.

firstdayofweek - Optional. A constant that specifies the first day of the week. If not specified, Sunday is assumed.

firstweekofyear - Optional. A constant that specifies the first week of the year. If not specified, the first week is assumed to be the week in which January 1 occurs.
 
Example:
 
MsgBox DateDiff("yyyy", "01/01/2005", "11/11/2006")
 
Above displays '1'.
 
Your specific example assumes your items are numeric
 
strBirthDate = Format(Day_Birth, "00") & "/" & Format(Month_Birth, "00") & "/" & cStr(Year_Birth)
 
intAge = DateDiff("yyyy", strBirthDate, Now( ))

--- On Thu, 5/28/09, abdul daulay <abdulhakimdaulay@yahoo.com> wrote:
>
> I want to make a school database, but I don't know how to get a student age. I have
> three field name=Day_Birth, Month_Birth and Year_Birth. Please help me...
>

[Non-text portions of this message have been removed]

__._,_.___
Recent Activity
Visit Your Group
Give Back

Yahoo! for Good

Get inspired

by a good cause.

Y! Toolbar

Get it Free!

easy 1-click access

to your groups.

Yahoo! Groups

Start a group

in 3 easy steps.

Connect with others.

.

__,_._,___

Nenhum comentário:

Arquivo do blog