Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. :) |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
=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. :) |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. :) |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. :) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Date & Time Question | Excel Discussion (Misc queries) | |||
Time and Date Question | Excel Discussion (Misc queries) | |||
Another question about time and date | Excel Discussion (Misc queries) | |||
Date/Time Question | Excel Worksheet Functions | |||
date/time question | Excel Programming |