Solved

Format Date time with no seconds

Posted on 2001-07-16
7
1,564 Views
Last Modified: 2009-03-02
Hi! When I FORMATDATETIME and specify 2 for e.g. FORMDATETIME(NOW(),2)...it gives me the time with seconds. How can I get rid of the seconds...I would like it to display

2:30 PM

instead of

2:30:00 PM

Please help
0
Comment
Question by:sheana
[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
7 Comments
 
LVL 20

Expert Comment

by:Silvers5
ID: 6288611
change the regional settings to not display seconds.. or try:

MyVar = Left(MyVar,len(MyVar)-6) & Right(MyVar,3)

Cdate it next if needed to be a date data type.. otherwise leave MyVar as is..
0
 
LVL 4

Expert Comment

by:ravi_raj123
ID: 6288632
HI,

Try using formatdatetime(Now(),4), this will give you the time in HH:MM format. 4=vbShortTime

Hope this helps you.
GOOD LUCK...:)

0
 

Accepted Solution

by:
indoria earned 50 total points
ID: 6288635
hi try this.....

<%
strAMPM = instr(1,FormatDateTime(now(),3),"AM")

if strAMPM > 0 then
 Response.Write FormatDateTime(now(),4)& " AM"
else
 strtime = mid(FormatDateTime(now(),3),1,5)
 Response.Write strtime & " PM"
end if
%>

indoria
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:sheana
ID: 6288686
Thanks.

<%
strAMPM = instr(1,FormatDateTime(now(),3),"AM")

if strAMPM > 0 then
Response.Write FormatDateTime(now(),4)& " AM"
else
strtime = mid(FormatDateTime(now(),4),1,5)
Response.Write strtime & " PM"
end if
%>
This code worked perfectly.

Thanks Indoria.

0
 

Expert Comment

by:indoria
ID: 6288722
hi again .. herez little modification in previous code..

<%
strAMPM = instr(1,FormatDateTime(now(),3),"AM")
if strAMPM > 0 then
 Response.Write FormatDateTime(now(),4)& " AM"
else
  strtime = mid(FormatDateTime(now(),3),1,5)
  if mid(strtime,len(strtime),1) = ":" then
    Response.Write  mid(strtime,1,len(strtime)-1) & " PM"
  else
    Response.Write strtime & " PM"
  end if
end if
%>

This is tested on Win envi.
indoria
0
 

Expert Comment

by:indoria
ID: 6288728
hi again .. herez little modification in previous code..

<%
strAMPM = instr(1,FormatDateTime(now(),3),"AM")
if strAMPM > 0 then
 Response.Write FormatDateTime(now(),4)& " AM"
else
  strtime = mid(FormatDateTime(now(),3),1,5)
  if mid(strtime,len(strtime),1) = ":" then
    Response.Write  mid(strtime,1,len(strtime)-1) & " PM"
  else
    Response.Write strtime & " PM"
  end if
end if
%>

This is tested on Win envi.
indoria
0
 

Author Comment

by:sheana
ID: 7024026
The above code does not work....PLEASE HELP! I tried it recently and now it does not work. I have made no changes.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Select record with the most recent date 14 72
Code Manager | Snippits 2 93
Send form to asp server side 6 38
Table doesn't show the lines! 3 36
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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/…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

751 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