Format Time 
Author Message
 Format Time

Does anyone know how I can format the time into 12 hour format without the
seconds?

I have tried FormatDateTime  and I get either seconds or 24 hour format. Is
there a way to specify the format I want e.g.: Format(datDate, hh:mm AMPM)?

Thanks for the help



Thu, 26 Jul 2001 03:00:00 GMT  
 Format Time

Quote:

>Does anyone know how I can format the time into 12 hour format without the
>seconds?

Not using the built-in functions. The two functions below will do the job,
buy note that I am being patriotic and assuming that the user has Australian
conventions for displaying the date / time ;-) Other people may display them
differently, which is why it is best to get the format from the Registry.

Peter

--
Peter Torr, Developer / Webmaster, Vantage Systems Australia.

Function Format12Hour(date)

 Dim iHour
 Dim bPm

 iHour = Hour(date)
 If (iHour >= 12) Then
  bPm = True
  iHour = iHour - 12
 End If

 If (iHour = 0) Then
  iHour = 12
 End If

 If (bPm) Then
  Format12Hour = FormatWidth(iHour, 2) & ":" & FormatWidth(Minute(date), 2)
& " PM"
 Else
  Format12Hour = FormatWidth(iHour, 2) & ":" & FormatWidth(Minute(date), 2)
& " AM"
 End If
End Function

Function FormatWidth(val, width)

 Dim iLen

 iLen = Len(val)

 If (iLen < width) Then
  FormatWidth = String(width - iLen, "0") & val
 Else
  FormatWidth = val
 End If
End Function

Response.Write "<p>" & Format12Hour(Now()) & "</p>"



Fri, 27 Jul 2001 03:00:00 GMT  
 Format Time
You can easily roll your own custom date formatting routines with the
"DatePart" function.

Eric



Quote:
> Does anyone know how I can format the time into 12 hour format without the
> seconds?

> I have tried FormatDateTime  and I get either seconds or 24 hour format.
Is
> there a way to specify the format I want e.g.: Format(datDate, hh:mm
AMPM)?

> Thanks for the help



Fri, 27 Jul 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Formatting Time to GMT when current Time Zone not known

2. Formatting time in military format

3. Formatting Time

4. Format Time Not to Show Seconds

5. Formatting Time

6. Format time doesn't work

7. format time-field in MSFlexgrid

8. How to Format Time Fields in Crystal Reports

9. Need the difference between two Medium format times...

10. Convert FORMAT TIME...

11. Trying to format time - My way

12. Problem w/Access '97 and Crystal Reports Formatting Time Fields

 

 
Powered by phpBB® Forum Software