IIf Statement with a date/time field

Liz_I3

Well-known Member
Joined
Dec 30, 2002
Messages
647
Office Version
  1. 2016
Platform
  1. Windows
Hello
I have a date/time field called Message Date/Time and another field called IN I want to create a new field called Time IN and have with this : Time In: IIf([IN]="IN",[Message Date/Time],"") It does give me the correct result but as text. I want to keep it as a date and time so that I can do calculations. I tried TimeValue which does work except if there is not date if gives #Error and then the calculations don't work either.

My end result is I have a start date/time and an end date/time and I want to subtract the 2 to get total time spent. But both start and end date/times have numerous entries per day so for the start time I need the first time in and for the End time the last time out
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
You can format the date and time using =DATE & =TIME for using them and use a combination =SUMPRODUCT with MAX function for each day to get the end time for each day and use =MIN function to get first time IN for each day...
 
Upvote 0
Have you tried 0 for the date if not in?
Dates are helds as numbers internally.
 
Upvote 0

Forum statistics

Threads
1,214,806
Messages
6,121,667
Members
449,045
Latest member
Marcus05

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