sheana
asked on
Format Date time with no seconds
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
2:30 PM
instead of
2:30:00 PM
Please help
HI,
Try using formatdatetime(Now(),4), this will give you the time in HH:MM format. 4=vbShortTime
Hope this helps you.
GOOD LUCK...:)
Try using formatdatetime(Now(),4), this will give you the time in HH:MM format. 4=vbShortTime
Hope this helps you.
GOOD LUCK...:)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
<%
strAMPM = instr(1,FormatDateTime(now
if strAMPM > 0 then
Response.Write FormatDateTime(now(),4)& " AM"
else
strtime = mid(FormatDateTime(now(),4
Response.Write strtime & " PM"
end if
%>
This code worked perfectly.
Thanks Indoria.
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
<%
strAMPM = instr(1,FormatDateTime(now
if strAMPM > 0 then
Response.Write FormatDateTime(now(),4)& " AM"
else
strtime = mid(FormatDateTime(now(),3
if mid(strtime,len(strtime),1
Response.Write mid(strtime,1,len(strtime)
else
Response.Write strtime & " PM"
end if
end if
%>
This is tested on Win envi.
indoria
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
<%
strAMPM = instr(1,FormatDateTime(now
if strAMPM > 0 then
Response.Write FormatDateTime(now(),4)& " AM"
else
strtime = mid(FormatDateTime(now(),3
if mid(strtime,len(strtime),1
Response.Write mid(strtime,1,len(strtime)
else
Response.Write strtime & " PM"
end if
end if
%>
This is tested on Win envi.
indoria
ASKER
The above code does not work....PLEASE HELP! I tried it recently and now it does not work. I have made no changes.
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..