Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

vbMediumTime!?

LEGEND ,
Jul 31, 2008 Jul 31, 2008
Is there any way to format the time section of a smalldatetime field to:

HH:mm AM/PM

Seems there's every format, except that one! Reckon I'm jinxed.

Nath.


TOPICS
Server side applications
449
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 01, 2008 Aug 01, 2008
tradmusic.com wrote:
> Is there any way to format the time section of a smalldatetime field to:
>
> HH:mm AM/PM
>
> Seems there's every format, except that one! Reckon I'm jinxed.
>
> Nath.

Try this: http://www.codetoad.com/asp/format_date_time.asp

Steve
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 01, 2008 Aug 01, 2008
Hi Steve,

Followed that link, but there's nothing there!
It gives you either HH:mm:ss AM/PM or HH:mm and I need HH:mm AM/PM!

This is what I was meaning. It seems like there is every way of doing it,
apart from the way I need!

If I've got 01/10/2008 14:30:00 in my smalldatetime field, I want to be able
to display the time simply as:

14:30 PM

Is this possible?

Thanks again.
Nath.


"Dooza" <doozadooza@gmail.com> wrote in message
news:g6uh6j$5vb$3@forums.macromedia.com...
> tradmusic.com wrote:
>> Is there any way to format the time section of a smalldatetime field to:
>>
>> HH:mm AM/PM
>>
>> Seems there's every format, except that one! Reckon I'm jinxed.
>>
>> Nath.
>
> Try this: http://www.codetoad.com/asp/format_date_time.asp
>
> Steve


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 01, 2008 Aug 01, 2008
tradmusic.com wrote:
> Hi Steve,
>
> Followed that link, but there's nothing there!
> It gives you either HH:mm:ss AM/PM or HH:mm and I need HH:mm AM/PM!
>
> This is what I was meaning. It seems like there is every way of doing it,
> apart from the way I need!
>
> If I've got 01/10/2008 14:30:00 in my smalldatetime field, I want to be able
> to display the time simply as:
>
> 14:30 PM
>
> Is this possible?

It doesn't look like there is a built in way to do this, I guess its
because the time is in 24 hour format already.

To do what you want your going to need to be clever and program it.

First you convert the time into 14:30, then keep just the first 2
character, convert it to a number, and then if the number is less than
12 output AM, else output PM. It might be easier to do in SQL, so I will
put my thinking cap on and see what I can do for you. My next break is
at 12:30 so will see what I can do then.

Steve
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 01, 2008 Aug 01, 2008
Hi again,

Just to say that I've tried to cheat it a little, with the following:

<%IF FormatDateTime((rsEvent.Fields.Item("eventdatetime").Value),
vbShortTime) > "11:59" Then %>
<%= FormatDateTime((rsEvent.Fields.Item("eventdatetime").Value),
vbShortTime) %> PM
<%ELSE%>
<%= FormatDateTime((rsEvent.Fields.Item("eventdatetime").Value),
vbShortTime) %> AM
<%End IF%>

...seems to have done the trick! What a "carry on" though! :o)

Nath.


"Dooza" <doozadooza@gmail.com> wrote in message
news:g6uh6j$5vb$3@forums.macromedia.com...
> tradmusic.com wrote:
>> Is there any way to format the time section of a smalldatetime field to:
>>
>> HH:mm AM/PM
>>
>> Seems there's every format, except that one! Reckon I'm jinxed.
>>
>> Nath.
>
> Try this: http://www.codetoad.com/asp/format_date_time.asp
>
> Steve


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 01, 2008 Aug 01, 2008
LATEST
tradmusic.com wrote:
> Hi again,
>
> Just to say that I've tried to cheat it a little, with the following:
>
> <%IF FormatDateTime((rsEvent.Fields.Item("eventdatetime").Value),
> vbShortTime) > "11:59" Then %>
> <%= FormatDateTime((rsEvent.Fields.Item("eventdatetime").Value),
> vbShortTime) %> PM
> <%ELSE%>
> <%= FormatDateTime((rsEvent.Fields.Item("eventdatetime").Value),
> vbShortTime) %> AM
> <%End IF%>
>
> ...seems to have done the trick! What a "carry on" though! :o)

Well done! Its these little tricks that help get the job done that help
us learn.

Here is an SQL solution:

SELECT DATENAME(hh,GETDATE()) + ':' + DATENAME(mi,GETDATE()) + CASE WHEN
DATENAME(hh,GETDATE()) >= '12' THEN ' PM' ELSE ' AM' END AS Time

Steve
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines