What I am actually doing is a MS Query to pull over data to Excel and then I
need to manipulate the data to come up in 4 buckets: Over 11 weeks, 6 to 10
weeks, 1 to 5 weeks, and Current Week. I am having a hard time writing a
nested If statement for that to look at the date and then in another column
fill the cell with one of the buckets noted above. Right now my statement
looks like this:
If(D2 <= today()-77,"11+ Weeks",If(D2 < today()-70,"6 to 10 Weeks",If(D2 <
today()-35,"1 to 5 Weeks",If(D2 > today()-7,"Current Week"))))
It seems to run okay for 11+ Weeks and Current Week but not the other two
buckets. Perhaps it would be better to do in VBA and attach the code to a
button but not sure how to write that since I am new to programming.
Thanks for your time!
fredg said:
I need to convert the date that comes up in the result of an access query to
text for exporting to Excel. I want the 5 digit number as the result rather
than a normal date. So instead of 9/26/2008, I want the result to be 39717.
Can I do a function or expression in a query to provide that result?
Covert to Text. Why text? I'm sure you meant Number.
But then, you can export the date field as a regular date, so why
change it to it's number (or text) value?
As a Number it must be a Long Integer value:
Clng([YourDateField])
? CLng(Date())
39717
to accommodate any date value larger than the maximum Integer size of
32,767 (which is 9/16/1989).
If you must have the result as a String, then:
? CStr(CLng(Date()))
39717