Karen Schaefer
asked on
Date dif between 7 days of current date
what is the correct syntax for plus or minus 7 days from current date?
I tried:
Here is the value of the field in the query - I needed to reformat the date into the correct format.
IIf(IsNull([EFFECT_HIRE_DA TE]),"",Da teSerial(C Int(Left([ EFFECT_HIR E_DATE],4) ),CInt(Mid ([EFFECT_H IRE_DATE], 5,2)),CInt (Right([EF FECT_HIRE_ DATE],2))) )
I need to limit the query to the between -7 and +7 of current date.
Here what I have so far for the critieria:
Between DateAdd("d",-7,Date()) And DateAdd("d",7,Date())
current Results -
STATUS_DATE
8/15/2012 7:40:17 PM
9/1/2011 6:40:05 PM
4/25/2011 7:08:32 PM
8/15/2012 7:40:17 PM
As you can see it is not returning the correct results if current date = 9/4/2012
I tried:
Here is the value of the field in the query - I needed to reformat the date into the correct format.
IIf(IsNull([EFFECT_HIRE_DA
I need to limit the query to the between -7 and +7 of current date.
Here what I have so far for the critieria:
Between DateAdd("d",-7,Date()) And DateAdd("d",7,Date())
current Results -
STATUS_DATE
8/15/2012 7:40:17 PM
9/1/2011 6:40:05 PM
4/25/2011 7:08:32 PM
8/15/2012 7:40:17 PM
As you can see it is not returning the correct results if current date = 9/4/2012
ASKER
Text, I think - it is coming from an oracle table and the format is as follows
yyyymmdd - hence the need to convert the format to mm/dd/yyyy.
Note; I also tried in the criteria using NOW() instead of Date(). The field properties of the query is set for short date
K
yyyymmdd - hence the need to convert the format to mm/dd/yyyy.
Note; I also tried in the criteria using NOW() instead of Date(). The field properties of the query is set for short date
K
And if it has time associated with it, it won't help you out
CInt(Right([EFFECT_HIRE_DA TE],2))))
CInt(Right([EFFECT_HIRE_DA
ASKER
Values from the oracle table for
EFFECT_HIRE_DATE
20111110
20050627
20110420
20110606
20060816
20120413
20101022
20120824
EFFECT_HIRE_DATE
20111110
20050627
20110420
20110606
20060816
20120413
20101022
20120824
Is the conversion being done correctly?
Try:
CDate(format(EFFECT_HIRE_D ATE,"0000/ 00/00")) Between (Date()-7) AND (Date()+7)
CDate(format(EFFECT_HIRE_D
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for the input
You are welcome!
/gustav
/gustav
pT72