Solved

Format Date time with no seconds

Posted on 2001-07-16
7
1,557 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
7 Comments
 
LVL 20

Expert Comment

by:Silvers5
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:sheana
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now