By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,646 Members | 2,105 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,646 IT Pros & Developers. It's quick & easy.

change date format to 'Morning', 'Noon' and 'Afternoon'

P: 5
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
Dec 18 '07 #1
Share this Question
Share on Google+
9 Replies


QVeen72
Expert 100+
P: 1,445
Hi,

Extract the TimePart from the Date, Use a "Select Case" or "IF" condtion to print the Day Part..

REgards
Veena
Dec 18 '07 #2

debasisdas
Expert 5K+
P: 8,127
You simply need to extract the time part only anc compare as per youir range and display accordingly.
Dec 18 '07 #3

P: 5
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:

Expand|Select|Wrap|Line Numbers
  1. Function Value
  2.  
  3.    If Not IsNull(DeadLine) Then
  4.       If TimeValue(DeadLine) = 0 Then
  5.          Value = Format(DeadLine, "dd/mm/yyyy")
  6.       Else
  7.          If DateValue(DeadLine) = 0 Then
  8.             Value = Format(DeadLine, "hh:mm")
  9.          Else
  10.             Value = Format(DeadLine, "dd/mm/yyyy, hh:mm")
  11.          End If
  12.          Value = Value & " uur"
  13.      End If
  14.      Value = Value
  15.    End If
  16.  
  17.    If Not IsNull(Me.EstimatedTime) Then
  18.       If Value > "" Then
  19.          Value = Value & ", "
  20.       End If
  21.       Value = Value & "duur ca." & Format(Me.EstimatedTime, "0.0#") & " uur."
  22.    End If
  23.  
  24. End Function


So I want to take the hour from this:
Expand|Select|Wrap|Line Numbers
  1.  
  2. Function TimeOfDay()
  3.    If TimeValue(Me.EstimatedTime()) < 11 Then
  4.       TimeOfDay = "Voormiddag"
  5.    End if
  6.  
  7.    If TimeValue(Me.EstimatedTime()) =>11 AND TimeValue(Me.EstimatedTime()) < 13 Then
  8.       TimeOfDay = "Middag"
  9.    End if
  10.  
  11.    If TimeValue(Me.EstimatedTime()) => 13 Then
  12.       TimeOfDay = "Namiddag"
  13.    End if
  14. End Function

But it doesn't work ....

Can you help me plz?
Thanks.
Dec 18 '07 #4

debasisdas
Expert 5K+
P: 8,127
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.
Dec 18 '07 #5

P: 5
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 ....
Dec 18 '07 #6

QVeen72
Expert 100+
P: 1,445
Hi,

Dont Use, TimeValue ...

Use Hour(MyDate) in your TimeOfDay function..

REgards
Veena
Dec 18 '07 #7

debasisdas
Expert 5K+
P: 8,127
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.
Dec 18 '07 #8

P: 5
Hi,

Dont Use, TimeValue ...

Use Hour(MyDate) in your TimeOfDay function..

REgards
Veena
Thank you so much! It works!! :)
Dec 18 '07 #9

Expert 5K+
P: 8,434
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.
Dec 18 '07 #10

Post your reply

Sign in to post your reply or Sign up for a free account.