Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

24 hour clock

Status
Not open for further replies.

dendic

Programmer
Jan 19, 2003
106
US
I'm using this code trying to achieve a 24 hour clock variable.
Dim varStartTime As Date, varEndTime As Date
varStartTime = "10:00"
varEndTime = "14:00"
varStartTime = Format(varStartTime, "short time")
varEndTime = Format(varEndTime, "short time")
But I keep getting AM/PM values.
 
Have you looked at the formats you have set up under Regional Settings in the Control Panel? These settings control the way a number formats are shown.
 
As Remou said, otherwise, convert the "short time" variable,
to a string...


Dim varStartTime As Date, varEndTime As Date
Dim strStartTime as string, strEndTime as string

varStartTime = "10:00"
varEndTime = "14:00"

strStartTime = Format(varStartTime, "short time")
strEndTime = Format(varEndTime, "short time")


 





Hi,

You are mixing metaphores, so to speak.

Date/Time is not STRING!!!
Code:
Dim varStartTime As [b]Date[/b], varEndTime As [b]Date[/b]
[b]dim sStartTime as string, sEndTime as string[/b]
varStartTime = #10:00#
varEndTime = #14:00#
[b]sStartTime[/b] = Format(varStartTime, "short time")
[b]sEndTime[/b] = Format(varEndTime, "short time")

Skip,
[sub]
[glasses] [b][red][/red][/b]
[b][/b] [tongue][/sub]
 
furthermore, if you don't want to depend on regional settings:
sStartTime = Format(varStartTime, "[!]HH:NN[/!]")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top