Error when deleting ProjectStart date and 31/09/2004

E

Ec

Hello

i am trying to determine the number of days between the
project start date and the end of the month (only if
ProjectEndDate is next month)

I have the following code
If Me.EndMonthOf = 9
Then
lngDuration = DateDiff("d", Me.[ProjectBeginDate], Me.
[ProjectEndDate])
Else
lngDuration = DateDiff("d", Me.[ProjectBeginDate],
#31/9/2004#)
End If

I get an error with the Else statement and i think it has
to do with the #31/9/2004# expression

Any ideas?
 
M

Michel Walsh

Hi,


In US, the date format is month/day/year, so, I would try:

#9/31/2004#


since # implies that the date will be first look as if it was an American
format.


(also, THEN is supposed to be on the same line that the starting IF, unless
you use the line continuation character).


Hoping it may help,
Vanderghast, Access MVP
 
G

Guest

I changed the date to the US format but unfortunately it
did not help

Im almost certain the date format is correct. Prior to
the IF statement, i have another statetement i.e.:

lngStart = DateDiff("d", #1/9/2004#, Me.
[ProjectBeginDate])

The system returns a value for this.
-----Original Message-----
Hi,


In US, the date format is month/day/year, so, I would try:

#9/31/2004#


since # implies that the date will be first look as if it was an American
format.


(also, THEN is supposed to be on the same line that the starting IF, unless
you use the line continuation character).


Hoping it may help,
Vanderghast, Access MVP


Hello

i am trying to determine the number of days between the
project start date and the end of the month (only if
ProjectEndDate is next month)

I have the following code
If Me.EndMonthOf = 9
Then
lngDuration = DateDiff("d", Me.[ProjectBeginDate], Me.
[ProjectEndDate])
Else
lngDuration = DateDiff("d", Me.[ProjectBeginDate],
#31/9/2004#)
End If

I get an error with the Else statement and i think it has
to do with the #31/9/2004# expression

Any ideas?


.
 
M

Michel Walsh

Hi,

Does it returns the right result? 1/9/2004 can be the First of September
2004 or the 9th of January 2004.

Once the form is open, and the control filled, does the statement, in the
immediate debug window:

? DateDiff("d", Me.[ProjectBeginDate], #9/31/2004#)

works? (error or not? right result, or not? ).




Hoping it may help,
Vanderghast, Access MVP



I changed the date to the US format but unfortunately it
did not help

Im almost certain the date format is correct. Prior to
the IF statement, i have another statetement i.e.:

lngStart = DateDiff("d", #1/9/2004#, Me.
[ProjectBeginDate])

The system returns a value for this.
-----Original Message-----
Hi,


In US, the date format is month/day/year, so, I would try:

#9/31/2004#


since # implies that the date will be first look as if it was an American
format.


(also, THEN is supposed to be on the same line that the starting IF, unless
you use the line continuation character).


Hoping it may help,
Vanderghast, Access MVP


Hello

i am trying to determine the number of days between the
project start date and the end of the month (only if
ProjectEndDate is next month)

I have the following code
If Me.EndMonthOf = 9
Then
lngDuration = DateDiff("d", Me.[ProjectBeginDate], Me.
[ProjectEndDate])
Else
lngDuration = DateDiff("d", Me.[ProjectBeginDate],
#31/9/2004#)
End If

I get an error with the Else statement and i think it has
to do with the #31/9/2004# expression

Any ideas?


.
 
M

Michel Walsh

Hi,


Good catch... since there is no 31st of September. Not having use 2004,
but just 04, that would have be another story:

? CDate(#31/9/04#)
1931-09-04

( my regional setting projects my preferences as yyyy-mm-dd )


Vanderghast, Access MVP
 

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

Top