Date Time Question

S

srroduin

I'm writing code that will subtract one hour from the time that the person
types in. If the person types only a date and not a time Excel defaults to
00:00 for the time portion. That's the answer I want for that case only.

How would I word an if statement to say if SASStartHE is typed as date 00:00
then SASStartHE = SASStart else SASStart = Dateadd("h", -1, SASStartHE).


Any ideas are greatly appreciated. :)
 
B

Bob Phillips

=IF(SASStartHE=0,0,SASStartHE-TIME(1,0,0))

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)
 
T

Tom Ogilvy

if Int(SASStartHE) = SASStartHE then
' do nothing
else
SASStart = Dateadd("h", -1, SASStartHE)
end if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top