Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default USING THE NESTED IF FUNCTION TO SEE IF A TIME DATE VALUE IS T OR F

If time is between 7am and 11am = morning
If time is between 12pm and 5 pm = afternoon
If time is 5pm and < 7pm = Evening
If time is between 7pm and 11pm = Night
If time is between 12am and 6am = midnite

I am having trouble getting the time component of the "DATE TIME" 6/02/03
12:21 AM - to be evaluated by the formula.
Any help would be greatly appreciated

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 156
Default USING THE NESTED IF FUNCTION TO SEE IF A TIME DATE VALUE IS T OR F

Are you trying to do this in a formula or VBA?
gunnerpatt wrote:
If time is between 7am and 11am = morning
If time is between 12pm and 5 pm = afternoon
If time is 5pm and < 7pm = Evening
If time is between 7pm and 11pm = Night
If time is between 12am and 6am = midnite

I am having trouble getting the time component of the "DATE TIME" 6/02/03
12:21 AM - to be evaluated by the formula.
Any help would be greatly appreciated

Thanks


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 156
Default USING THE NESTED IF FUNCTION TO SEE IF A TIME DATE VALUE IS T OR F

Here's a VBA Function that might help
Click alt+F11 to open VBE (visual basic editor). Click Insert ==
Module, paste the code below into the window.

Function TimeTest(ByVal target As Date) As String
On Error Resume Next
If TimeValue(target) = #7:00:00 AM# And TimeValue(target) < #12:00:00
PM# Then
TimeTest = "Morning"
ElseIf TimeValue(target) = #12:00:00 PM# And TimeValue(target) <
#5:00:00 PM# Then
TimeTest = "Afternoon"
ElseIf TimeValue(target) = #5:00:00 PM# And TimeValue(target) <
#7:00:00 PM# Then
TimeTest = "Evening"
ElseIf TimeValue(target) = #7:00:00 PM# And TimeValue(target) <
#12:00:00 AM# Then
TimeTest = "Night"
ElseIf TimeValue(target) = #12:00:00 AM# And TimeValue(target) <
#7:00:00 AM# Then
TimeTest = "Midnight"
Else
TimeTest = "Error"
End If
End Function


Now use this function in your spreadsheet =TimeTest(Time) where "time"
is the cell you want to test, ie. =TimeTest(A1)

hope this work for you

Sandy


gunnerpatt wrote:
If time is between 7am and 11am = morning
If time is between 12pm and 5 pm = afternoon
If time is 5pm and < 7pm = Evening
If time is between 7pm and 11pm = Night
If time is between 12am and 6am = midnite

I am having trouble getting the time component of the "DATE TIME" 6/02/03
12:21 AM - to be evaluated by the formula.
Any help would be greatly appreciated

Thanks


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 156
Default USING THE NESTED IF FUNCTION TO SEE IF A TIME DATE VALUE IS T OR F

Here's a VBA Function that might help
Click alt+F11 to open VBE (visual basic editor). Click Insert ==
Module, paste the code below into the window.

Function TimeTest(ByVal target As Date) As String
On Error Resume Next
If TimeValue(target) = #7:00:00 AM# _
And TimeValue(target) < #12:00:00 PM# Then
TimeTest = "Morning"
ElseIf TimeValue(target) = #12:00:00 PM# _
And TimeValue(target) < #5:00:00 PM# Then
TimeTest = "Afternoon"
ElseIf TimeValue(target) = #5:00:00 PM# _
And TimeValue(target) < #7:00:00 PM# Then
TimeTest = "Evening"
ElseIf TimeValue(target) = #7:00:00 PM# _
And TimeValue(target) < #12:00:00 AM# Then
TimeTest = "Night"
ElseIf TimeValue(target) = #12:00:00 AM# _
And TimeValue(target) < #7:00:00 AM# Then
TimeTest = "Midnight"
Else
TimeTest = "Error"
End If
End Function


Now use this function in your spreadsheet =TimeTest(Time) where "time"
is the cell you want to test, ie. =TimeTest(A1)

hope this work for you

Sandy


gunnerpatt wrote:
If time is between 7am and 11am = morning
If time is between 12pm and 5 pm = afternoon
If time is 5pm and < 7pm = Evening
If time is between 7pm and 11pm = Night
If time is between 12am and 6am = midnite

I am having trouble getting the time component of the "DATE TIME" 6/02/03
12:21 AM - to be evaluated by the formula.
Any help would be greatly appreciated

Thanks


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 618
Default USING THE NESTED IF FUNCTION TO SEE IF A TIME DATE VALUE IS T OR F

You have been incnsistent as to where you drew your boundaries in some
cases, but try
=IF(HOUR(A1)<7,"midnite",IF(HOUR(A1)<12,"morning", IF(HOUR(A1)<17,"afternoon",IF(HOUR(A1)<19,"Evening ","Night"))))
--
David Biddulph

"gunnerpatt" wrote in message
...
If time is between 7am and 11am = morning
If time is between 12pm and 5 pm = afternoon
If time is 5pm and < 7pm = Evening
If time is between 7pm and 11pm = Night
If time is between 12am and 6am = midnite

I am having trouble getting the time component of the "DATE TIME" 6/02/03
12:21 AM - to be evaluated by the formula.
Any help would be greatly appreciated

Thanks



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 formulas DRondeau Excel Discussion (Misc queries) 7 September 6th 06 09:53 PM
Date Function Khangura Excel Discussion (Misc queries) 1 December 21st 05 09:33 AM
How do I calculate if a date is in a certain time frame? Pe66les Excel Worksheet Functions 19 August 27th 05 11:07 PM
help with date and time wayne visser Excel Worksheet Functions 1 June 14th 05 04:10 PM
Automatically enter date and time but only update once. PM New Users to Excel 3 January 21st 05 07:47 AM


All times are GMT +1. The time now is 09:51 AM.

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

About Us

"It's about Microsoft Excel"