DateDiff problem

J

JoeP

I have a field that was imported as part of a text file. The field comes in
as a string of numbers 20090107 which I have converted to a date using
DateSerial function and it now appears in the calculated field StartConvert
as 2009-01-07.

I want to calculate how many days from the date in StartConvert to today's
date which right now is Jan 28 2010. I use the following calculation...

TestDate: DateDiff("d",[StartConvert],Date()). I receive the answer 20 when
in fact the answer should be 385.

What am I doing wrong?
Thanks for any help.

JoeP
 
J

Jerry Whittle

Since you only want days, try this:

TestDate: Date() - [StartConvert]

This assumes that StartConvert is a date field.

A very strange possibility would be that the date in you PC is really wrong.
 
G

ghetto_banjo

i was thinking the same thing that possibly the date on the PC is
wrong.

you could also try putting CDate([StartConvert]) to make sure it is
being processed as a correct date format in the datediff function.
 
J

John W. Vinson

I have a field that was imported as part of a text file. The field comes in
as a string of numbers 20090107 which I have converted to a date using
DateSerial function and it now appears in the calculated field StartConvert
as 2009-01-07.

What's your actual conversion expression? I.e. is StartConvert a Date/Time
field (the result of the DateSerial function directly), or a Text field
(wrapping DateSerial in a Format)?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

DateDiff 4
Data Type Mismatch in Criteria Expression 4
DateDiff Problem 4
DateDiff 13
Age 9
datediff 4
Datediff 2
calculate difference between dates 5

Top