Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Aug 2002
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Time displays as long though medium date used (2003)

    Hello,

    In my Access table I have a time field formatted as medium time (hh:mm AM/PM). However when I display it on my HTML using ASP is shows up as a long date (HH:MM:SS AM/PM) which just shows too many zeros as it is just an hourly type time field. I have found info on making it short or long but can find nothing on making it display as medium and I need the AM/PM for sorting purposes. It seems it should display as medium by default since it is medium in the table? Below is the code displaying the time. Does anyone have a suggestion? "Event_Time" is the field name.

    Response.Write "[B]<FONT FACE='Verdana, Arial' SIZE='1' COLOR='Red'>" & vbCrLf
    Response.Write Replace(Rs("Event_Time") & " ", vbCrLf, "") & vbCrLf
    Response.Write "</FONT>" & vbCrLf

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Time displays as long though medium date used (2003)

    The format of a field in a table is only a way of displaying the field in Access itself; VBScript and ASP don't know about it.

    Try using Format(Rs("Event_Time"),"hh:mm AM/PM") instead of RS("Event_Time").

  3. #3
    Lounger
    Join Date
    Aug 2002
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Time displays as long though medium date used (2003)

    Thanks Hans,

    IS this correct?

    Response.Write Replace(Format(Rs("Event_Time"),"hh:mm AM/PM") & " ", vbCrLf, "") & vbCrLf

    I recieve an error on display "Type mismatch: 'Format' " So I must still be doing something wrong. Thank you so much for your help!

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Time displays as long though medium date used (2003)

    I'm not into VBScript and ASP, so I don't know what's possible and what isn't.
    1. Is Event_Time a date/time field?
    2. Does it work if you use

    Response.Write Format(Rs("Event_Time").Value,"hh:mm AM/PM") & " " & vbCrLf

  5. #5
    Lounger
    Join Date
    Aug 2002
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Time displays as long though medium date used (2003)

    No it still does not work. Same error but thank you very much for trying Hans [img]/forums/images/smilies/smile.gif[/img]

  6. #6
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Time displays as long though medium date used (2003)

    I don't know much about ASP, but don't think you're going to be able to use Format function directly in the "Response.Write" instruction. What you probably need to do is, do not use table directly as data source for ASP page, instead use query based on table as data source. The query should include a calculated field like this example:

    SELECT Format([Event_Time],"hh:nn AM/PM") AS Event_Time_Med
    FROM TABLE1;

    Note you will need to alias the field in the query as shown, and revise the ASP code to reference the aliased field name (Event_Time_Med). Also the Access query designer automatically uses "nn" for formatting minutes when using Format function.

    HTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •