Combining date and time into one field

Status
Not open for further replies.

Dave M

Member
Outlook version
Outlook 2007
Email Account
Exchange Server 2007
Hello,

I would like to take the date portion of one field and combine it with the time portion of another field in a third field in a custom form. I'm familiar with the datevalue() and timevalue() functions, but can't seem to get the syntax right to have the third field display properly. Any help would be greatly appreciated.

Field1 = "9/18/14 7:00am"
Field2 = "10/2/14 12:00pm"

would like Field3 to equal "9/18/14 12:00pm"

Thanks,

Dave M.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
This should work -
field3 = DateValue(field1) & " " & TimeValue(field2)
will display as 9/18/2014 12:00:00 PM

for other date/time formats, you need to use format()
DateValue(field1) & " " & Format(TimeValue(field2), "hh:mmampm")
returns
9/18/2014 12:00PM

for lowercase am/pm, use /
Format(TimeValue(field2), "hh:mmam/pm")
9/18/2014 12:00pm
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Sorry, I missed the 2 digit year.
Format(DateValue(field1), "m/d/yy") & " " & Format(TimeValue(field2), "hh:mmam/pm")
9/18/14 12:00pm
 
Status
Not open for further replies.
Top