Results 1 to 3 of 3

Thread: Date format with Vb script

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 1999
    Location
    Belfast
    Posts
    254
    Hi,
    is there any date formatting facility in VBScript? I want to use ASP to return the date from today till 31 days from now to populate a list box. However I want the date as a string i.e. "10 Oct. 2000" etc. so there can be no confusion as to the exact date. The normal VB format functionality doesn't seem to apply. My simple source is below:

    <%

    '//=========================================================
    '// Populate list box with dates for the next 31 days
    '//=========================================================

    dim day_count
    day_count = 0

    Response.Write "<SELECT NAME=selListBox>"
    do until day_count = 31
    Response.Write " <option>" & date() + day_count & "</option>"
    day_count = day_count + 1
    loop
    Response.Write "</SELECT>"
    %>


  2. #2
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    Hi lenin

    all you need is the formatdatetime function

    Code:
    <html>
    <body>
    <% 
    '//========================================================= 
    '// Populate list box with dates for the next 31 days 
    '//========================================================= 
    
    dim day_count 
    day_count = 0 
    
    Response.Write "<SELECT NAME=selListBox>" 
    do until day_count = 31 
    Response.Write " <option>" & FormatDateTime(date() + day_count,vbLongDate) & "</option>" 
    day_count = day_count + 1 
    loop 
    Response.Write "</SELECT>" 
    %> 
    </body>
    </html>
    Hope this helps

    Ian
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 1999
    Location
    Belfast
    Posts
    254
    That's the ticket.

    Many thanks Ian.

Posting Permissions

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



Click Here to Expand Forum to Full Width