Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default 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. :)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default 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. :)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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. :)



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default 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. :)




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date & Time Question sot Excel Discussion (Misc queries) 7 October 30th 07 06:43 PM
Time and Date Question wx4usa Excel Discussion (Misc queries) 6 October 8th 07 03:34 AM
Another question about time and date ECLynn Excel Discussion (Misc queries) 2 August 30th 06 10:13 PM
Date/Time Question bladelock Excel Worksheet Functions 2 November 10th 05 02:42 AM
date/time question mk Excel Programming 5 June 7th 05 12:32 PM


All times are GMT +1. The time now is 03:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"