Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

datetime field in access 2003

May 7, 2007 6:49PM PDT

goal: to create a table containing information about meeting events

each record contains information relating to a weekly meeting event. each event meets on a specific day of the week, e.g. monday, tuesday

I have made a custom format dddd in the format field properties

Access gives me an error when I enter 'Monday'
"The value you entered isn't valid for this field.

what am I doing wrong?

Discussion is locked

- Collapse -
Re: date-time format
May 7, 2007 8:09PM PDT

Just enter the date in the format defined for Windows, like mm/dd/yyyy or dd-mm-yy. Access will calculate if it's Monday or Wednesday and show it in return.

No need to enter 'Monday 1/1/2007' and impossible to enter 'Wednesday 1/1/2007' (it was a Monday).

Hope this helps.


Kees

- Collapse -
only certain data
May 8, 2007 4:28AM PDT

I forgot to mention that I am not interested in any data describing month-day-year, in fact, it would be rather counterproductive for this table. I am only interested in the weekday.

This table is going to have about 200 rows when completed so that users can query against using SQL statements

(e.g. select meeting_name, city_location, keywords, weekday from the table which meet on tuesday between 6:00 pm and 10:00 or on Friday beween 7:00pm and 10:00pm having keywords ='women only' and bookstudy
group by city_location , time
order by weekday)

or something like that. so the fact that it is may 14th 2007 or sept 23 or october 28 is irrelevant because all of these meetings occur in a regular pattern, ie, daily, several times a week, or weekly - every week, every month, all year round.

Sorry I left that information out - I was tired. thanks for any further help

- Collapse -
In that case ...
May 8, 2007 7:41AM PDT

just define a dropdown box for a text field with values "Sunday", "Monday", etc (7 in total).

Let me mention that this should be considered a 'repeating group', so you would need two tables to get a database in BCNF that can be searched easily. Same as with keywords (assuming such meetings can have several keywords. But that's not the problem you've got here.

Hope this helps.


Kees

- Collapse -
Great advice
May 8, 2007 9:11AM PDT

Thank you. That sounds like one way to plan this out.

I was also just now thinking what I can do is to t create a new table with (startdate datetime) column. create another table with numbers 1 to 7 included as n.

Then run a query:
selecting format(startdate + n, 'dddd') as weekday
from the table with startdate
and the table with n
order by startdate+n

and save that as a new table which will then give me the weekday without any other datetime format.

then when I build my meeting table I can use this new table to define the dayoftheweek of the meeting.

Do you this will work?

- Collapse -
sigh - probably limitation with access
May 8, 2007 9:52AM PDT

well I made one table with a startdate, another with a number from 0 - 6
and I ran this sql query

select format(startdate+n, 'dddd') as weekday
into weekday
from startweek,
weekcount;

and now weekday shows sunday through saturday

but the datatype is text.

oh well...

- Collapse -
Re: dates in Access
May 8, 2007 4:52PM PDT

If startdate + 6 was a saturday, than one day later (startdate + 7) is a sunday. So simply add 1-7 (or 8-13, if you like) in stead of 0-6.

Dates and weekdays are like social security numbers and first names.
There are 365 dates in 2007, and 53 of those are called 'monday'. But 'monday' isn't a date, so you can't enter it into a date-field.
There are - say - 200 SSN's in your company's personnel database. And some - say 7 - are called John. But 'John' isn't a SSN, so you can't enter it a SSN-filed. And that's why you need to work with text in stead of a date. And it doesn't matter at all if you start with text or find some way (like a date format, or a complicated nested if, or your own VBA-function) to start with a number and transform it into text.

Good luck with your endeavors.

Kees