change date format to 'Morning', 'Noon' and 'Afternoon' | Newbie | | Join Date: Dec 2007
Posts: 4
| | |
Hi,
I'm sure this has been done before, but I can't seem to find this one on the net....
I have a datefield but instead of it just displaying:
07/12/18 08:30
I would like to display it as: 07/12/18 MORNING
or when it's 07/12/18 12:00 as: 07/12/18 NOON
and 07/12/18 14:30 as: 07/12/18 AFTERNOON
From 00:00 till 11:30 = MORNING
from 11:30 till 13:30 = NOON
from 13:30 till 17:00 = AFTERNOON
Can someone plz help me with this?
Thanks alot in advance!
Joachim
|  | Moderator | | Join Date: Oct 2006 Location: Bangalore
Posts: 1,385
| | | re: change date format to 'Morning', 'Noon' and 'Afternoon'
Hi,
Extract the TimePart from the Date, Use a "Select Case" or "IF" condtion to print the Day Part..
REgards
Veena
|  | Moderator | | Join Date: Dec 2006 Location: Bangalore ,India
Posts: 7,508
| | | re: change date format to 'Morning', 'Noon' and 'Afternoon'
You simply need to extract the time part only anc compare as per youir range and display accordingly.
| | Newbie | | Join Date: Dec 2007
Posts: 4
| | | re: change date format to 'Morning', 'Noon' and 'Afternoon' Quote:
Originally Posted by QVeen72 Hi,
Extract the TimePart from the Date, Use a "Select Case" or "IF" condtion to print the Day Part..
REgards
Veena This is what I have: -
Function Value
-
-
If Not IsNull(DeadLine) Then
-
If TimeValue(DeadLine) = 0 Then
-
Value = Format(DeadLine, "dd/mm/yyyy")
-
Else
-
If DateValue(DeadLine) = 0 Then
-
Value = Format(DeadLine, "hh:mm")
-
Else
-
Value = Format(DeadLine, "dd/mm/yyyy, hh:mm")
-
End If
-
Value = Value & " uur"
-
End If
-
Value = Value
-
End If
-
-
If Not IsNull(Me.EstimatedTime) Then
-
If Value > "" Then
-
Value = Value & ", "
-
End If
-
Value = Value & "duur ca." & Format(Me.EstimatedTime, "0.0#") & " uur."
-
End If
-
-
End Function
So I want to take the hour from this: -
-
Function TimeOfDay()
-
If TimeValue(Me.EstimatedTime()) < 11 Then
-
TimeOfDay = "Voormiddag"
-
End if
-
-
If TimeValue(Me.EstimatedTime()) =>11 AND TimeValue(Me.EstimatedTime()) < 13 Then
-
TimeOfDay = "Middag"
-
End if
-
-
If TimeValue(Me.EstimatedTime()) => 13 Then
-
TimeOfDay = "Namiddag"
-
End if
-
End Function
But it doesn't work ....
Can you help me plz?
Thanks.
|  | Moderator | | Join Date: Dec 2006 Location: Bangalore ,India
Posts: 7,508
| | | re: change date format to 'Morning', 'Noon' and 'Afternoon'
you need to capture only the hour from time part in 24 hrs format and compare the same in a simple select case and display as desired.
| | Newbie | | Join Date: Dec 2007
Posts: 4
| | | re: change date format to 'Morning', 'Noon' and 'Afternoon' Quote:
Originally Posted by debasisdas you need to capture only the hour from time part in 24 hrs format and compare the same in a simple select case and display as desired. Sorry, but i'm a real newbie.
Can you help me with the code please?
Thanks ....
|  | Moderator | | Join Date: Oct 2006 Location: Bangalore
Posts: 1,385
| | | re: change date format to 'Morning', 'Noon' and 'Afternoon'
Hi,
Dont Use, TimeValue ...
Use Hour(MyDate) in your TimeOfDay function..
REgards
Veena
|  | Moderator | | Join Date: Dec 2006 Location: Bangalore ,India
Posts: 7,508
| | | re: change date format to 'Morning', 'Noon' and 'Afternoon'
Do not post duplicate threads or send PM to anyone it is strictly against forum rules. Do as sugested by our expert in the previous post.
| | Newbie | | Join Date: Dec 2007
Posts: 4
| | | re: change date format to 'Morning', 'Noon' and 'Afternoon' Quote:
Originally Posted by QVeen72 Hi,
Dont Use, TimeValue ...
Use Hour(MyDate) in your TimeOfDay function..
REgards
Veena Thank you so much! It works!! :)
| | Moderator | | Join Date: Oct 2006 Location: Australia
Posts: 7,748
| | | re: change date format to 'Morning', 'Noon' and 'Afternoon' Quote:
Originally Posted by debasisdas Do not ... send PM to anyone it is strictly against forum rules This is a valid point, but comes across in this post as a slight exaggeration. I'd just like to clarify.
It is not "strictly against forum rules" to send anyone a PM. Private Messages are often used to chat "off list" to avoid cluttering up the discussion forum. But for technical questions and answers we want everything in the forum so it's available for later reference. TheScripts is all about the free exchange of information, so discussing these things in private goes against that ideal.
|  | Similar Visual Basic 4 / 5 / 6 bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,449 network members.
|