|
-
Jan 13th, 2004, 02:52 PM
#1
Thread Starter
New Member
Calculating between 2 dates
Hi everyone,
i'm working with msaccess forms.
I have 2 dates: date1 - date2
For example, date1= #01/01/2003# and date2= #03/01/2004#
I used dateresult= -datediff("y",[date2],[date1]) and it's just gives me dateresult = 1
I want to get as a result the number of years, the number of months and number of days.
Please I need your help.
Sorry for my bad english!
-
Jan 14th, 2004, 01:05 PM
#2
PowerPoster
how about
years = datediff("yyyy",date1,date2)
months = (years * 12) - datediff("m",date1,date2)
I'm not sure about the days
-
Jan 14th, 2004, 11:48 PM
#3
Member
VB Code:
Years = DateDiff("yyyy", Date1, Date2)
Months = DateDiff("m", Date1, Date2)
Days = DateDiff("d", Date1, Date2)
-
Jan 15th, 2004, 05:39 AM
#4
Fanatic Member
whats wrong with temp=Date1 - Date2? the result should be a value that expresses a time span in VB one would then take Hour(temp) Day(temp) Year(temp)...
It's pritty much the same but I was just wondering.
-
Jan 15th, 2004, 01:34 PM
#5
PowerPoster
Wouldn't that just give you the same time amount only expressed in different units?
It would be Years = Months = Days
instead of
Years + months + days
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|