Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why am I getting this result from datediff? 1

Status
Not open for further replies.

LaurieHamlin

Programmer
Feb 6, 2003
217
US
Here's what I have:
tday = Format(#7/16/03#, "m/d/yy") (changed from Date() to #7/16/03# to see if that was the problem)
wkend = Format(InputBox(Chr(10) & "Enter pay period ending date" & Chr(13) & Chr(10) & Chr(10) & Chr(10) & Chr(10) & Chr(10) & "As MM/DD/YY", "Week End Date"), "m/d/yy")

I'm entering 7/25/03 for wkend. When I print the vars they're both correct, yet when I do datediff:
futuredt = DateDiff("d", tday, wkend)
and print futuredt it says 1/8/1900
A few lines down I check wkend against another date and the datediff works fine.
????????????????????????????????????????????????
Please let me know if you have any ideas. Thanks.
 
Hi LaurieHamlin,
That happens because you have declared "futuredt" as a Date. You should declare it as an integer (or any numeric variable) since the value dateDiff returns is a number, not a date. Your code is converting the "9" you should receive to a Date (1/8/1900). That should solve your problem.
 
The simplest things are often the hardest to see.
Thanks for saving lots of frustration.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top