Results 1 to 11 of 11
  1. #1
    New Lounger
    Join Date
    Jan 2001
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Response.Write date format

    I'm accessing a SQL server database using Javascript ASP code (I'm new in Javascript). My problem is with the date format using Response.Write. If I switch to HTML and use <%=adoRecordSet("EffectiveDate").Value%> I get the date in the short date format (e.g., 12/11/1997), which is what I want. If I stay in ASP and use Response.Write(adoRecordSet('EffectiveDate').Value ), I get a long date format (e.g., Thu Dec 11 00:00:00 CST 1997).

    I want to stay in ASP, as I hear that runs faster. How can I stay in ASP and still get short date format? Is there something I can do in the SQL statement, or alternatively in the Javascript code?

    Thanks in advance for your help.

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sydney, Australia, New South Wales, Australia
    Posts
    251
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Re: Response.Write date format

    Have a look into the Format function in ASP / VBScript.

  3. #3
    New Lounger
    Join Date
    Jan 2001
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Response.Write date format

    Any way to do this in ASP/Javascript if ASP/VBScript is not an option?

  4. #4
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Minneapolis, Minnesota, USA
    Posts
    262
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Response.Write date format

    See if this - specifically, the solution to Exercise 2. Good luck!
    <font face="Comic Sans MS"><font color=blue>~Shane</font color=blue></font face=comic>

  5. #5
    New Lounger
    Join Date
    Jan 2001
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Response.Write date format

    Thanks so much. In principle this works, but is it possible to access the client-side function from server-side ASP script?

  6. #6
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Minneapolis, Minnesota, USA
    Posts
    262
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Response.Write date format

    I think I may have just gotten confused about what you're trying to do, but let me take a crack at it.

    Yes, in your .ASP page, you can specify that a chunklet of script should run on the client. But, from your original post, I was under the impression that you wanted to format the date as your .ASP page was being processed on the server. Did I misunderstand?

    Edited for grammar -- Shane
    <font face="Comic Sans MS"><font color=blue>~Shane</font color=blue></font face=comic>

  7. #7
    New Lounger
    Join Date
    Jan 2001
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Response.Write date format

    Sorry I'm exposing my greenness. Yes, I am trying to format the date as my .ASP page is being processed on the server. Theoretically I could use the VBScript format function but I'm using JavaScript, and looking for the equivalent format capability. Is there a way to include the function you recommended within the ASP code itself, or otherwise handle this date reformatting? Hope this is still not confusing, and appreciate your attempt to help out!

  8. #8
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sydney, Australia, New South Wales, Australia
    Posts
    251
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Re: Response.Write date format

    Also worth noting is that you can have more than one language inside an ASP script. I think it's <%@ language="vbscript" %> to change the language half way through.
    vbScript is already on the server (if it's IIS?), so you shouldn't need to install anything.

  9. #9
    New Lounger
    Join Date
    Jan 2001
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Response.Write date format

    Shane, I apologize, your code as originally suggested works after all. I just made some mistake when including it within the ASP. Thanks for bearing with me.

  10. #10
    New Lounger
    Join Date
    Jan 2001
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Response.Write date format

    Thanks for the suggestion. I was able to make use of Shane Sargent's JavaScript suggestion (separate post), but this is useful to know (and I may still use it if there is any speed advantage).

  11. #11
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Minneapolis, Minnesota, USA
    Posts
    262
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Response.Write date format

    Glad it worked out in the end. Best of luck!
    <font face="Comic Sans MS"><font color=blue>~Shane</font color=blue></font face=comic>

Posting Permissions

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