how to change a date depending on time of day?

A

apolite

Hi,
I am fairly new user and am attempting to create a form that will enter
data into a report. The data that is being entered will be dated and if the
data is entered after 2:00 PM then the entry date is to display the following
day instead of the date of entry, somewhat like a funds being deposited in a
bank after 2:00 in the afternoon. I would appreciate very much if someone
could help me with the code to resolve this issue.

Thank You
 
J

John W. Vinson

Hi,
I am fairly new user and am attempting to create a form that will enter
data into a report. The data that is being entered will be dated and if the
data is entered after 2:00 PM then the entry date is to display the following
day instead of the date of entry, somewhat like a funds being deposited in a
bank after 2:00 in the afternoon. I would appreciate very much if someone
could help me with the code to resolve this issue.

Thank You

Do you want to store just the date, or the date and time? If it's entered
after 2:00 on a Friday do you want to enter Saturday's date, or the next
Monday? What if Monday is a holiday?
 
W

Wayne-I-M

To follow on from John's question. I asume you will have the date and time
like this

22/03/2008 09:56:54
13/09/2006 14:56:54
etc


In a query you could use something like this

SomeName:
IIf((DatePart("h",TablenName!TimeField))>#14:00:00#,DateAdd("d",1,TablenName!TimeField))

You would need to set the format to display just the date section

HTH
 
W

Wayne-I-M

ooops

Just tested it and it should be

SomeName:
IIf((TimeValue([TablenName]![TimeField]))>#14:00:00#,[TablenName]![TimeField]+1,[TablenName]![TimeField])
 
F

fredg

Hi,
I am fairly new user and am attempting to create a form that will enter
data into a report. The data that is being entered will be dated and if the
data is entered after 2:00 PM then the entry date is to display the following
day instead of the date of entry, somewhat like a funds being deposited in a
bank after 2:00 in the afternoon. I would appreciate very much if someone
could help me with the code to resolve this issue.

Thank You

How and where is the date being entered?
Here is an expression that will do what you ask. Where you place it is
determined by how and where you are doing it.

IIf(TimeValue(Now())>#2:00:00 PM#,Date()+1,Date())
 
A

apolite

These are very pertinent questions and I thank you for your foresight. For
one I would only like to store the date, also I would not really like to
store Saturday's date but rather the next business day exactly as a bank
would do.

Thanks
 
A

apolite

Sorry, this gives me the error "#NAME?" in the text box and this is even when
I enter a time value in [TablenName]![TimeField].
Wayne-I-M said:
ooops

Just tested it and it should be

SomeName:
IIf((TimeValue([TablenName]![TimeField]))>#14:00:00#,[TablenName]![TimeField]+1,[TablenName]![TimeField])
--
Wayne
Manchester, England.



Wayne-I-M said:
To follow on from John's question. I asume you will have the date and time
like this

22/03/2008 09:56:54
13/09/2006 14:56:54
etc


In a query you could use something like this

SomeName:
IIf((DatePart("h",TablenName!TimeField))>#14:00:00#,DateAdd("d",1,TablenName!TimeField))

You would need to set the format to display just the date section

HTH
 
A

apolite

fredg said:
How and where is the date being entered?
Here is an expression that will do what you ask. Where you place it is
determined by how and where you are doing it.

IIf(TimeValue(Now())>#2:00:00 PM#,Date()+1,Date())
 

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

Top