Results 1 to 2 of 2

Thread: Date formatting confusion

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2001
    Location
    Calgary, AB Canada
    Posts
    42

    Date formatting confusion

    I am working on fixing an ASP.NET app someone else wrote.

    I have access to the actual page through terminal server, and have downloaded the source.

    Here is the oddity.

    Code:
      Dim dt as date
    
      dt = today.month & "/" & today.day & "/" & today.year
    The code above produces an error when I run it on my workstation.
    Windows XP Service Pack 2. It also produces an error on my laptop, same operating system.

    This DOES NOT produce an error on the server that the original code still runs on. Windows 2000 Server.

    This DOES NOT produce an error on my workstation if it is run with VB.NET.

    for it to work properly in my asp page the code needs to be as follows.

    Code:
      dt = today.day & "/" & today.month & "/" & today.year
    I find this bewildering. My short date setting is M/d/yy so that can't be the issue. Why is ASP.NET behaving differently from my VB.NET on my own workstation, and again differently from the ASP.NET on the target server??

    I can write a workaround that tries both methods, but it doesn't seem logiical to have to do that.

    Any ideas?

  2. #2
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492

    Re: Date formatting confusion

    Originally posted by Burrick
    I am working on fixing an ASP.NET app someone else wrote.

    I have access to the actual page through terminal server, and have downloaded the source.

    Here is the oddity.

    Code:
      Dim dt as date
    
      dt = today.month & "/" & today.day & "/" & today.year
    The code above produces an error when I run it on my workstation.
    Windows XP Service Pack 2. It also produces an error on my laptop, same operating system.

    This DOES NOT produce an error on the server that the original code still runs on. Windows 2000 Server.

    This DOES NOT produce an error on my workstation if it is run with VB.NET.

    for it to work properly in my asp page the code needs to be as follows.

    Code:
      dt = today.day & "/" & today.month & "/" & today.year
    I find this bewildering. My short date setting is M/d/yy so that can't be the issue. Why is ASP.NET behaving differently from my VB.NET on my own workstation, and again differently from the ASP.NET on the target server??

    I can write a workaround that tries both methods, but it doesn't seem logiical to have to do that.

    Any ideas?
    Use Format() and Now()

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