ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Date Time Question (https://www.excelbanter.com/excel-programming/361962-date-time-question.html)

srroduin

Date Time Question
 
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. :)

Bob Phillips[_14_]

Date Time Question
 
=IF(SASStartHE=0,0,SASStartHE-TIME(1,0,0))

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"srroduin" wrote in message
...
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. :)




Tom Ogilvy

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

--
Regards,
Tom Ogilvy



"srroduin" wrote in message
...
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. :)




srroduin

Date Time Question
 
It worked great! Thanks so much.

"Tom Ogilvy" wrote:

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

--
Regards,
Tom Ogilvy



"srroduin" wrote in message
...
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. :)






All times are GMT +1. The time now is 03:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com