Hi,
When pulling the hour (or minute, or second, or day, or month, etc) from
the server like:
<%= hour(time) %>
Is there a quick way (like, without an if then statement to check it and
fix it) to format it so it represents all hours in two digits like:
00
for 12 am. instead of just:
0
?
Thanks. 14 8832
Hi.
Take a look at function FormatDateTime( ): http://msdn.microsoft.com/library/de...atdatetime.asp
Travis Pupkin wrote: <%= hour(time) %>
Is there a quick way (like, without an if then statement to check it and fix it) to format it so it represents all hours in two digits like:
--
Kai Boenke, QI/LBS-Hi
Robert Bosch GmbH Hildesheim
It's a pity that FormatDateTime won't do what you want, nor will
FormatCurrency etc.
You're probably stuck with creating a small function to return the formatted
string eg.
Function AddExtraZerosIf Req(plngValue)
Dim pstrValue
Dim plngChars
Dim i
pstrValue = CStr(plngValue)
plngChars = Len(pstrValue)
If plngChars < 2 Then
For i = 1 to plngChars Step -1
pstrValue = "0" & pstrValue
Next
End If
AddExtraZerosIf Req = pstrValue
End Function
And referencing it as:
<%= AddExtraZerosIf Req(Hour(time)) %>
NB: This would be easy in Visual Basic, it would be:
Format(time, "00")
Why they missed this obvious functionality from VBScript is beyond me!
Hope this helps,
Chris.
"Kai Boenke" <ka********@de. bosch.com> wrote in message
news:bn******** **@ns2.fe.inter net.bosch.com.. .
Hi.
Take a look at function FormatDateTime( ): http://msdn.microsoft.com/library/de...atdatetime.asp
Travis Pupkin wrote: <%= hour(time) %>
Is there a quick way (like, without an if then statement to check it and fix it) to format it so it represents all hours in two digits like:
--
Kai Boenke, QI/LBS-Hi
Robert Bosch GmbH Hildesheim
Or more simply <%=Right('0' & Hour(Time()),2) %>
HTH
Chris
<in awe>
I didn't see that particular solution but I like it.
</in awe>
Chris.
"CJM" <cj*****@yahoo. co.uk> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Or more simply <%=Right('0' & Hour(Time()),2) %>
HTH
Chris http://www.aspfaq.com/2300
"Travis Pupkin" <tp*****@dorrk. com> wrote in message
news:MP******** *************** *@news.individu al.net... Hi,
When pulling the hour (or minute, or second, or day, or month, etc) from the server like:
<%= hour(time) %>
Is there a quick way (like, without an if then statement to check it and fix it) to format it so it represents all hours in two digits like:
00
for 12 am. instead of just:
0
?
Thanks.
Elegant. I plan to use that technique. Thanks.
"CJM" <cj*****@yahoo. co.uk> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. Or more simply <%=Right('0' & Hour(Time()),2) %>
HTH
Chris
In article <Oz************ **@tk2msftngp13 .phx.gbl>, chris@blue-
canoe.co.uk.NOS PAM says... <in awe> I didn't see that particular solution but I like it. </in awe>
Chris.
Don't be too awed Chris, your suggested worked much better. Although I
would prefer something as simple CJM's code, it didn't account for the
occasional two digits (and would replace the first of the two with a
'0', so at 2 p.m., instead of '14' you'd get '04'.
But your function is as close as I can get to something lean.
Thanks. This group always kicks ass.
Errm,
Wouldn't it just do:
Hour = "14"
Append a zero to give "014" and then take the rightmost two digits to give
"14" again.
Chris.
"Travis Pupkin" <tp*****@dorrk. com> wrote in message
news:MP******** *************** *@news.individu al.net...
In article <Oz************ **@tk2msftngp13 .phx.gbl>, chris@blue-
canoe.co.uk.NOS PAM says... <in awe> I didn't see that particular solution but I like it. </in awe>
Chris.
Don't be too awed Chris, your suggested worked much better. Although I
would prefer something as simple CJM's code, it didn't account for the
occasional two digits (and would replace the first of the two with a
'0', so at 2 p.m., instead of '14' you'd get '04'.
But your function is as close as I can get to something lean.
Thanks. This group always kicks ass.
A possible typo for VBScript [strings]?
<%=Right('0' & Hour(Time()),2) %>
should be:
<%=Right("0" & Hour(Time()),2) %>
Double quotes instead of single-quotes?
Chris.
"Travis Pupkin" <tp*****@dorrk. com> wrote in message
news:MP******** *************** *@news.individu al.net...
In article <Oz************ **@tk2msftngp13 .phx.gbl>, chris@blue-
canoe.co.uk.NOS PAM says... <in awe> I didn't see that particular solution but I like it. </in awe>
Chris.
Don't be too awed Chris, your suggested worked much better. Although I
would prefer something as simple CJM's code, it didn't account for the
occasional two digits (and would replace the first of the two with a
'0', so at 2 p.m., instead of '14' you'd get '04'.
But your function is as close as I can get to something lean.
Thanks. This group always kicks ass. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gord |
last post by:
Hello,
VB6 accepts Date and Time values as 'Date'. I'm trying to verify entry into
a database I'm creating by verifying that an appropriate Date or Time value
has been entered. Using built-in VB functions/properties etc., I can't seem
to unambiguously confirm that an entry is a valid date or valid time value?
(I would like to try and do this without having to write some huge procedure
that processes an entry character by character,...
|
by: T-Narg |
last post by:
I would like to produce the following output based on my XML file:
My Album (2005)
Elapsed Time (hh:mm:ss): 00:07:00
Song 1: title1
Length (hh:mm:ss): 00:02:30
Song 2: title2
Length (hh:mm:ss): 00:02:15
|
by: Kenneth |
last post by:
Hello,
I'm having some serious problems debugging a script that I'm trying to make
work. I'm working on a form where a user can type in a time (in the format
of HH:MM), and another script automatically calculate how much time is
inbetween.
That part of it is working fine, but what ISN'T working fine is the script
that validates whether or not the user has entered the time in proper
syntax, and to make sure that the Time In does not...
|
by: Rene |
last post by:
I am currently displaying the time of day value using the "h:mm:ss tt"
format (hr=hours, mm=minutes, ss=seconds tt=AM/PM).
I was looking under the "Regional and Language Options" and it looks like
the day time representation on all of the countries in the world always
start with Hours, then Minutes and Finally Seconds.
It appeared that the only difference is that different countries represent
the AM and PM differently but I am assuming...
|
by: Edward Mitchell |
last post by:
I have a number of DateTimePicker controls, some set to dates, some set to a
format of Time. The controls are all embedded in dialogs. I created the
controls by dragging the DateTime picker from the Toolbox and then set the
Format property appropriately.
I have noticed that sometimes the Time format will reset spontaneously to
Short Date. I looked at the .rc file and found that the usual form for a
Short Date is as follows:
CONTROL ...
| |
by: scorpion53061 |
last post by:
What I thought would be pretty easy has turned out not to be.
I have three variables. Actiontime is formatted as 08/11/2004 11:03PM
Actiontime
JobStreamStart (11:00:00PM)
JobStreamEnd (2:00:00AM)
If (Format(CDate(ActionTime), "t") >= JobStreamStart AND
(Format(CDate(ActionTime), "t") < jobstreamend Then
|
by: Khurram |
last post by:
I have a problem while inserting time value in the datetime Field.
I want to Insert only time value in this format (08:15:39) into the SQL
Date time Field.
I tried to many ways, I can extract the value in timeonly format by using
this command
Format(now,"HH:mm:ss")
But when I insert it into the Sql Server database, it embadded date value
with it.
the output looks like that "01/01/1900 08:59:00" in that case time is
|
by: Jerome |
last post by:
Hallo,
I know a lot has already been told about date/time fields in a database but
still confuses me, specif when dealing with SQLserver(Express).
It seems that sqlserver only accepts the date in a "yyyyMMdd" format?
(difference between Express and MSDE2000A ?)
What is the one and only true way to deal with this problem in VB2005:
Local settings are Dutch (Belgium) ; thus date is in "dd/MM/yy" (or perhaps
dd/MM/yyyy) and time in...
|
by: Dirk Hagemann |
last post by:
Hello,
From a zone-file of a Microsoft Active Directory integrated DNS server
I get the date/time of the dynamic update entries in a format, which
is as far as I know the hours since january 1st 1901.
For Example: the number 3566839 is 27.11.07 7:00. To calculate this in
Excel I use this:
="01.01.1901"+(A1/24-(REST(A1;24)/24))+ZEIT(REST(A1;24);0;0) (put
3566839 in field A1 and switch the format of the result-field to the
corresponding...
|
by: nospam |
last post by:
I have some data that I need to run date diffs on. The catch is that
for some of this data, there is a date value in one of the fields,
with no time. It might look like this:
ROW DT1 DT2
1 1/1/08 8:00 AM 1/1/08 10:00 AM
2 1/2/08 9:00 AM 1/2/2008
3 1/3/08 10:00 AM 1/3/08 12:00 PM
4 1/4/2008 1/4/08 1:00 PM
5 1/5/08 1:00 PM 1/5/08 2:00 PM
|
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...
| |
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,...
|
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...
|
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| |