An IF condition based on time

pedro-egoli

Well-known Member
Joined
Apr 25, 2004
Messages
1,217
Office Version
  1. 2016
Platform
  1. Windows
I currently have a cell with formula
Code:
=NOW()

This of course gives me todays date.
However, what I need is that todays date only appear after 5pm.

Background is that I take a solar reading at 5pm each day and this cell is used by a Summary sheet in a Month to Date column.

Not sure how to go about this so any help will be appreciated.

Pedro
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Thanks Jeff.
Tried that and got this answer
Code:
40641.38926

The time here in Australia is 9.20am

Pedro
 
Upvote 0
Yes you will have to set a format.

Select the cell >> Crtl + 1 >> Number tab >> select a format.

In Excel a date is on the left side of the decimal and the right side is the time.

40641 is 4/8/2011

.38926 is 9:20:32 AM
 
Upvote 0
Jeff,
Not quite sure how to go about this.
What I want is for the cell to be blank unless it is after 5 pm each day .

To enable me try some variations what is the number for 5pm?
Thanks
Pedro
 
Upvote 0
I'm sorry about that, just wasn't thinking...try this.

=IF(MOD(NOW(),1)>TIME(17,0,0),NOW(),"")

With using the Now() function it will only refresh when you recalculate the spreadsheet or on open.
 
Upvote 0
Jeff, that looks like it would work.
Thanks again for your patience.

Pedro
 
Upvote 0
Attention jeffreybrown,

In April jeffrey gave me a formula that would change the date after 5pm and it was
Code:
=IF(MOD(NOW(),1)>TIME(17,0,0),NOW(),"")

Because I wanted to use the date to take away from an earlier date , the result of which transferred to another sheet in workbook as number of days passed ,I changed formula to
Code:
=IF(MOD(NOW(),1)>TIME(17,0,0),NOW(),NOW()-1

Formula is in cell C1 of 1 worKsheet and preceding date is in B1. There is a separate worksheet for each month and figures are transferred to a summary sheet.
On main worksheet (workbook summary) I use this formula to calculate number of days
Code:
=DATEDIF('APRIL  2011  '!B1,'APRIL  2011  '!C1,"d")

On Summary sheet it has become apparent that this method is not working.
"May2011" number of days is now 34 because of the formula in the "MAY 2011" worksheet C1 showing 3/6/11.

So I need a bit of assistance please.

I still need to have the date in C1 change after 5 pm and am trying to work out how to do this.
In A4:A32 of monthly sheets I enter the date via "Ctrl+;" and what i would like to have is formula of "=MAX(A4:A32)" linked with the ">TIME(17,0,0)" function.
If it is not 5 pm the date in C1 to remain the same.

Thanks

Pedro
 
Upvote 0
Hi Pedro,

Not completely following what you need.

"May2011" number of days is now 34 because of the formula in the "MAY 2011" worksheet C1 showing 3/6/11.

From what I see C1 is setup to return Now() after 5:00 PM so 3/6/11 would be correct right? Not clear what is in B1.

In A4:A32 of monthly sheets I enter the date via "Ctrl+;"

May has 31 days so why a range of A4:A32 which is only 29 cells?

I understand you requirement to have the date change after 5:00 PM, but just can't reconcile what you want here or there.

Can you use one of the HTML maker's and post B1 and C1 with their formula's and what you expect after 5:00 PM? Also, please address the A4:A32 range?
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,756
Members
452,940
Latest member
rootytrip

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