Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Time Difference problem

Posted on 2002-04-24
3
Medium Priority
?
206 Views
Last Modified: 2010-05-02
Heres what I need to do:
1. get "day" start time, "night" start time, from user
2. get time right now
3. determine by the above info if it is presently "day"   or "night"
4. done

Sounds easy huh?  well I've had  a pretty hard time with it.

I would like accept values like "7:00 PM", "11:32 AM" for the start times, will this work?, or will it need to be 24 hour format?


Dave

 
0
Comment
Question by:DaveMon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Expert Comment

by:n_narayanan
ID: 6965193
its better you accept in 24 Hrs Format and check the current time is less than the night time then say "Day" otherwise Say "Night"

Thats it.

Narayanan
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 800 total points
ID: 6965200
The format is not really important:

Dim Morning As Double
Dim Night As Double
Dim Test As Double
Morning = CDbl(CDate(txtMorning.Text))
Night = CDbl(CDate(txtNight.Text))
Test = CDbl(CDate(txtTimeToTest.Text))
If Test < Morning Or Test > Night Then
  Msgbox "Nightime"
Else
  Msgbox "DayTime"
End If
0
 
LVL 3

Expert Comment

by:n_narayanan
ID: 6965204
Here is the code

Private sub cmdShow()
Dim tm As String
tm = Format(Now, "HH:MM:SS")
If tm < nightStart.Text Then
    MsgBox "Day"
Else
    MsgBox "Night"
End If
End Sub

Cheers

Narayanan
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

596 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question