473,394 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

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
9 2202
QVeen72
1,445 Expert 1GB
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
8,127 Expert 4TB
You simply need to extract the time part only anc compare as per youir range and display accordingly.
Dec 18 '07 #3
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
8,127 Expert 4TB
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
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
1,445 Expert 1GB
Hi,

Dont Use, TimeValue ...

Use Hour(MyDate) in your TimeOfDay function..

REgards
Veena
Dec 18 '07 #7
debasisdas
8,127 Expert 4TB
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
Hi,

Dont Use, TimeValue ...

Use Hour(MyDate) in your TimeOfDay function..

REgards
Veena
Thank you so much! It works!! :)
Dec 18 '07 #9
Killer42
8,435 Expert 8TB
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

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

Similar topics

12
by: Andrew | last post by:
Hi, I select from an Access table " where date >= '3/1/2004' and date <='3/31/2004' ", but no record. Can you tell me how to make this comparission? Thanks -- Andrew
5
by: goochey | last post by:
I'm trying to convert a Julian Date (Format "4365") into an actual calendar date in Visual Basic, can anyone help me out with this.
17
by: clintonG | last post by:
When the following code is run on Sat Dec 25 2004 19:54:18 GMT-0600 (Central Standard Time) var today = new Date(); var GMTDate = today.toGMTString(); document.write("GMTDate: " + GMTDate); ...
5
by: Macca | last post by:
Hi, I have a table which has a date/time field. I am storing them as follows :- 01/01/2005 11:25 01/01/2005 19:44 02/01/2005 05:04
3
by: DP | last post by:
hi, i've got this peice of code; <script language= "JavaScript"> var today = new Date(); var hourOfDay = today.getHours(); var message = " and welcome to MIS "; if (hourOfDay >=0 &&...
1
by: magix | last post by:
Hi, Do you have any javascript available for changing images according to time ? let say Morning (7am-12pm), using images 1 (e.g morning.jpg) Afternoon (12 - 6pm), using images 2 (e.g...
7
by: mr.nimz | last post by:
hello, this is antenio. recently i've come to a problem. i got a way through it, somehow, still it left me in a curious state, so i'm posting it here, if i can get an answer from some techy, ...
10
by: ARC | last post by:
Hello all, General question for back-end database that has numerous date fields where the database will be used in regions that put the month first, and regions that do not. Should I save a...
0
by: indefatigable | last post by:
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.