How to compute number of days using a single entry of Date ?

  • Thread starter Thread starter rock72
  • Start date Start date
R

rock72

I am developing a application using this fields as required by the
company.


1. Date Login
2. Time IN
3. Time OUT

My question is how to produce the number of days with 1 entry of Date
is the entry ? [Date Login]

Then, after getting the number of Days. Switching is needed for
weekdays and sundays. Note that if the Date is Sunday and that Sunday
does not pass 6 days from the previous Date Login, That Sunday will be
consider as WeekDay otherwise remain as Sunday.

How will I do That ? I already have this field in my query.

WkDay:IIF(Format([Dated],"dddd") <> "Sunday",1,0)

My only problem here is Sunday ’coz I cannot use this query:

Sunday:IIF(Format([Dated],"dddd") = "Sunday",1,0)

Although this will give a value 1 to my Sunday Remark field but it is
not the one required by my Boss. Read my 1st statement above in able
to figure out what to do ’coz I am also reviewing my work here though,
I can’t figure it out yet. Can you help ? I need it ASAP. Thanks
 
rock72 said:
I am developing a application using this fields as required by the
company.


1. Date Login
2. Time IN
3. Time OUT

My question is how to produce the number of days with 1 entry of Date
is the entry ? [Date Login]

Then, after getting the number of Days. Switching is needed for
weekdays and sundays. Note that if the Date is Sunday and that Sunday
does not pass 6 days from the previous Date Login, That Sunday will be
consider as WeekDay otherwise remain as Sunday.

How will I do That ? I already have this field in my query.

WkDay:IIF(Format([Dated],"dddd") <> "Sunday",1,0)

My only problem here is Sunday ’coz I cannot use this query:

Sunday:IIF(Format([Dated],"dddd") = "Sunday",1,0)

Although this will give a value 1 to my Sunday Remark field but it is
not the one required by my Boss. Read my 1st statement above in able
to figure out what to do ’coz I am also reviewing my work here though,
I can’t figure it out yet. Can you help ? I need it ASAP. Thanks

I have no idea what you are attempting to do. Sorry. However, instead
of your WkDay thingy, you can always use WeekDay(). Weekday() defaults
to Sunday being Day 1 and Saturday being Day 7. However, you can tell
which day the counting is to start from. Today is Wednesday, Dec 8, 2004.

? Weekday(Date(),vbMonday) 'use Monday as the 1st day of week
3
? Weekday(Date()) 'use default of Sunday as 1st day of week.
4

If you use vbMonday, but need to have it work in a query, you need to
substitute the value of vbMonday to its numeric value. Ex:
? vbMonday
2

Would you be better off using 2 date/time fields and store a value like
Now() to them? That way you have the starting day/time as well as the
ending day/time. You can extract the date from both...as well as the
time. You can add/subtract from them with date/time functions.

Some functions you may want to look at in on-line help are DateSerial,
TimeSerial, DateDiff, DateAdd, Year, Month, Day, Now, Date, Time, Hour,
Minute, Second.

Also check out http://www.mvps.org/access/datetime/index.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top