Solved

Time function needs to be 24 hour format

Posted on 2013-01-26
2
311 Views
Last Modified: 2013-01-26
My page here uses the following code to pull out the start and end times from the database for each event.

It's stored in the database fine in 24 hour time format, but I'm currently just getting the first integer for the hour and minute (e.g. '19 0' instead of '19:00').

Here's the part that handles the time:

  <div class="time">
      <div class="hour"><%=hour(rs("ca_starttime"))%></div>
      <div><%=minute(rs("ca_starttime"))%></div>
   </div> 

<div class="time">
      <div class="hour"><%=hour(rs("ca_endtime"))%></div>
      <div><%=minute(rs("ca_endtime"))%></div>
   </div> 

Open in new window


Many thanks.
0
Comment
Question by:UName10
[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 Comments
 
LVL 17

Accepted Solution

by:
wobbled earned 500 total points
ID: 38822223
How are the values stored in the database i.e. are you saving the hour and minute in different fields, if so are these fields set as integers rather than nvarchar etc.

If you wish to hold a number value that has a zero at the start you will need to store it as a string otherwise you will find the initial zero(s) are removed.

If you don't wish to change your database tables you could of course just right a small bit of code that checked if the value returned for minutes was only 1 charactor long and if so add a zero to the start of it.

I've quickly hacked a way of doing this below

Dim strMin = rs("ca_endtime")
e.g. If Len(strMin) = 1 Then strMin = "0" & strMin
0
 

Author Comment

by:UName10
ID: 38822241
Hi wobbled - thanks very much.

That's a good solution, I just added the following suggestion:
<%=Right("00" & minute(rs("ca_starttime")), 2)%>

Open in new window


Yours would work too however, so I'll accept that as the solution.

Many thanks.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

707 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