SUBTRACT DAYS FROM DATE

A

Akrt48

I have a very simple problem, but can't get it. I have a date stored in text
format, I want to take 7 days from it. I have tried [date]-7 which works
fine until we get one that goes backwards to 2005, then it doesn't work. I
have converted the date to "yyyy/mm/dd" and done [date2]-7 but still don't
get what I want, in fact everything becomes and error. Where am I going
wrong. Thanks
 
E

Ed Warren

The key is in your first sentence. "stored in a text format" -- its text
not a date. so dateadd will not work, until you convert it to a date\time
format. Either by changing the field type or through a convert function
like

cdate([textDate])

Then the function: DateAdd("d",-7,cdate([textdate]) will give you a date
result seven days before the [textdate]

Ed Warren.
 
A

Akrt48

Thanks worked well.

Ed Warren said:
The key is in your first sentence. "stored in a text format" -- its text
not a date. so dateadd will not work, until you convert it to a date\time
format. Either by changing the field type or through a convert function
like

cdate([textDate])

Then the function: DateAdd("d",-7,cdate([textdate]) will give you a date
result seven days before the [textdate]

Ed Warren.


Akrt48 said:
I have a very simple problem, but can't get it. I have a date stored in
text
format, I want to take 7 days from it. I have tried [date]-7 which works
fine until we get one that goes backwards to 2005, then it doesn't work.
I
have converted the date to "yyyy/mm/dd" and done [date2]-7 but still don't
get what I want, in fact everything becomes and error. Where am I going
wrong. Thanks
 
T

Tom Lake

Ed Warren said:
The key is in your first sentence. "stored in a text format" -- its text
not a date. so dateadd will not work, until you convert it to a date\time
format. Either by changing the field type or through a convert function
like

cdate([textDate])

Then the function: DateAdd("d",-7,cdate([textdate]) will give you a date
result seven days before the [textdate]

or just

CDate([textdate]) - 7

Tom Lake
 
Top