day calculation

S

SIN

hi,
how i calculation - day?
when i do that i get = 0

v_total_day > integer
rsInvoice(9) + v_sysdate > date
v_total_day = rsInvoice(9) - v_sysdate

thanks
 
J

John W. Vinson

hi,
how i calculation - day?
when i do that i get = 0

v_total_day > integer
rsInvoice(9) + v_sysdate > date
v_total_day = rsInvoice(9) - v_sysdate

thanks

You're assuming that we have some trace of an idea what v_total_day, integer,
rsInvoice(9) and v_sysdate are.

We cannot see your computer, and we don't.

The question "how i calculation - day" means nothing to me, nor do I
understand what you are trying to accomplish.

Please post a more detailed question. Note that the DateAdd() function (see
the online help) lets you add days (or any other time interval) to a date/time
value.

John W. Vinson [MVP]
 
I

i_takeuti

SIN said:
hi,
how i calculation - day?
when i do that i get = 0

v_total_day > integer
rsInvoice(9) + v_sysdate > date
v_total_day = rsInvoice(9) - v_sysdate

thanks
 
S

SIN

sorry,

dim v_total_day as integer
dim v_star_date as date
dim v_end_date as date

v_start_day = Format('11/04/2007', "\#mm\/dd\/yyyy\#")
v_end_date = Format('01/07/2007', "\#mm\/dd\/yyyy\#")

v_total_day = v_end_date - v_start_day

the right answer is 81 i get 0.

thanks.
 
J

John W. Vinson

sorry,

dim v_total_day as integer
dim v_star_date as date
dim v_end_date as date

v_start_day = Format('11/04/2007', "\#mm\/dd\/yyyy\#")
v_end_date = Format('01/07/2007', "\#mm\/dd\/yyyy\#")

v_total_day = v_end_date - v_start_day

The Format() function returns a text string, not a date nor a number.

I'm GUESSING that Access will see 11/04/2007 as an arithmatic expression - 11
divided by 4 divided by 2007 - when it's used in a subtraction, and the same
for 01/07/2007.

To get the number of days between two dates, use the DateDiff() function:

DateDiff("d", #11/04/2007#, #01/07/2007#)

Note that dates ARE NOT TEXT STRINGS, and ' is not an appropriate delimiter;
use # to delimit literal date values (and be aware that date literals are
assumed to be in American mm/dd/yyyy format).

John W. Vinson [MVP]
 
Top