Having issues with date and time

ssharm02

New Member
Joined
Oct 20, 2017
Messages
3
Hello everyone, my first post here :)

I am writing a VBA script to automate a task. I have a column which contains both date and time in the format of (yyyy/mm/dd h:mm:ss). I have to split the date and time and send it to an outlook method.

I did the following:
Code:
Dim startDateTime As String
Dim startTime As String
Dim startDate As String

inside a for each loop I get all the date and time values
Code:
startDateTime = row.Columns(5)
startDate= Left(rows.Columns(5), 10)
startTime = Right(rows.Columns(5),11)
For the most part this works, however 12:00:00 AM is automatically converted to 0:00 and when this is passed to the Outlook method, it crashes :(

I can't really change the format type because this data is coming from a sharepoint site, and its constantly refreshed.

I also set the startDateTime As Date and tried the following
Code:
startTime = TimeSerial(startDateTime) 'Hour(startDateTime) & ":" & Minute(startDateTime) & ":" & Second(startDateTime)

But that didn't work either.

One other thing, when I click a cell in the column, the date and time values are stored as an Integer (43031.5).

I have to use this data a lot, do comparisons with it. Any help will be appreciated! thank you
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Sorry the format of the date and time is:

yyyy/mm/dd h:mm (13:00 beyond are automatically converted to PM :P) And I don't have to worry about timezones (thankfully)
 
Upvote 0

Forum statistics

Threads
1,223,705
Messages
6,173,985
Members
452,540
Latest member
haasro02

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top