Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date minipulation 1

Status
Not open for further replies.

DBAMJA

Programmer
Jul 25, 2003
169
US
Having trouble figuring this one out. I know it can't be too hard but I don't think I've had enough coffee yet this morning.

My problem is, I have a date field [StartDate] in the format "7/31/2016 9:26:12 PM". If that date is a Sunday (which is easy to determine), I need to make that date the following morning at 7am or "8/1/2016 7:00:00 AM". I can't figure out how to programatically change the date.

Any ideas?

Any help and assistance is greatly appreciated.

[flush]

Michael

It is said that God will give you no more than you can handle. I just wish God didn't think I was just a bad ass.
 
Hi,

Assuming that [StartDate] is a real date...
Code:
NextDay = DateSerial(Year([StartDate]), Month([StartDate]), Day([StartDate])+1) + TimeSerial(7,0,0)

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Thanks a ton Skip.

[flush]

Michael

It is said that God will give you no more than you can handle. I just wish God didn't think I was just a bad ass.
 
Skip's example adds a day to the value of [StartDate] no matter what day of the week it is. Use the WeekDay function with vbSunday to determine if it is Sunday and then run his code if it is.
 
Hmmmmmmm????

"I have a date field [StartDate] in the format "7/31/2016 9:26:12 PM"
"I need to make that date the following morning at 7am"

Turns out, the date that the OP has is a Sunday.

Straining at a gnat?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top