473,748 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

5 New Member
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 2217
QVeen72
1,445 Recognized Expert Top Contributor
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 Recognized Expert Expert
You simply need to extract the time part only anc compare as per youir range and display accordingly.
Dec 18 '07 #3
indefatigable
5 New Member
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 Recognized Expert Expert
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
indefatigable
5 New Member
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 Recognized Expert Top Contributor
Hi,

Dont Use, TimeValue ...

Use Hour(MyDate) in your TimeOfDay function..

REgards
Veena
Dec 18 '07 #7
debasisdas
8,127 Recognized Expert Expert
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
indefatigable
5 New Member
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 Recognized Expert Expert
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
1763
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
16333
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
2510
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); The code returns: Sun, 26 Dec 2004 19:54:18 GMT (the next day after the code was actually run)
5
816
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
1646
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 && hourOfDay < 12) {
1
3705
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 afternoon.jpg) Night (6pm - 7am), using images 3 (e.g night.jpg) thanks. Magix
7
2770
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, here is my table structure, Name: Table1
10
5819
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 date format in the table design, such as: mm/dd/yyyy? What I've done for years is to store the date format in date fields, then on the forms, based on their region, I would set the date formats on form_load
0
852
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 DateValue(DeadLine) = 0 Then Value = Format(DeadLine, "hh:mm")
0
8983
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8822
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9359
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9310
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8235
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6072
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4592
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.