wanna date? hah

bpaquette

Registered User.
Local time
Today, 19:16
Joined
Aug 13, 2003
Messages
119
i haven't looked into this, but does anyone know if and how i can use dates in formulas? do standard operators work? does it calculate properly (diff't numbers of days in months, etc)



will something like


curdate = 21 jan 03


curdate - 30 (days) = 22 dec 02



and dare i ask about leap years :P
 
Access won't understand curdate unless you enclose it with hash/pounds symbol
 
are you saying thta if i enclose a curdate variable in #'s it will treat it as a number?

i'm a bit confused, can you offer an example?
 
Wouldn't you just be better using the DateAdd() function? It considers leap years, also, when performing calculations.
 
from what you say mile that looks like it'll be sufficient for what i need, i'll explore that func a little bit.


thanks for undoubtedly saving me tons of time snooping around help files :)
 
To clarify what Rich said, Access won't understand what you mean if you were to have the line:

Code:
curdate = 21 jan 03


To make Access recognise that the value being assigned to curdate is a date, we enclose it within hash marks.


Code:
curdate = #21-jan-03#
 
Hmz, Mile and his dateadd, undoubtably followed by datediff :(

?Date()
Gives todays date
When working with dates and DAYS there is no need to use dateadd or datediff you can do just what you want....

By enclosing with #'s you tell access to use it like a date
From the immidiat window:
?05-22-03
-20
?#05-22-03#
22-5-2003
Note: Access uses a mm/dd/yyyy format by default!! Be sure to remember that!!! Or make sure you use mmm or mmmm in your formatting....
?#02-25-04#+5
1-3-2004
As you can see adding with integers also takes leap into account...
?#03-25-04#-#02-25-04#
29
returning the number of days between 2 dates....

You run into 'problems' when wanting to get months/weeks/years difference and even going to Hours/minutes/secs will start getting harder. For those use datediff.

Regards
 
' course if you use queries/ calculated controls to return dates and date values you can stick with the European format:p
 
bpaquette said:
and dare i ask about leap years

That quote, namlian, is why I mentioned the DateAdd. ;)
 
namliam said:
?#02-25-04#+5
1-3-2004
As you can see adding with integers also takes leap into account...
?#03-25-04#-#02-25-04#
29

I may just be stubburn but .... it works doesnt it??

Regards
 

Users who are viewing this thread

Back
Top Bottom