ASP date problems.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TC

    ASP date problems.

    Hi.

    I have some ASP written in VB.net which is currently installed on a
    customers server. The asp connects to a local MySql database and retrieves
    data for the customers customers. If you see what I mean.

    The problem is their server insists on showing dates in the US format. The
    server has no other language installed than UK and all settings I can find
    are UK.

    My test server here, which as far as I can see is setup the same, shows
    dates in the correct UK format.

    Has anyone come accross this, or have any ideas?

    Cheers.


  • Claes Bergefall

    #2
    Re: ASP date problems.

    Could be a number of reasons for this, the first that comes to mind is that
    the web server account has the wrong regional info.

    I few questions:

    What code are you using to format the dates?
    Are you using the <globalizatione lement in your web.config (and if so, how
    is it set)?
    Is the US format consistant across different browsers/machines?

    /claes


    "TC" <tull@idcodewar e.co.ukwrote in message
    news:uIQNfLZmIH A.3512@TK2MSFTN GP03.phx.gbl...
    Hi.
    >
    I have some ASP written in VB.net which is currently installed on a
    customers server. The asp connects to a local MySql database and
    retrieves data for the customers customers. If you see what I mean.
    >
    The problem is their server insists on showing dates in the US format.
    The server has no other language installed than UK and all settings I can
    find are UK.
    >
    My test server here, which as far as I can see is setup the same, shows
    dates in the correct UK format.
    >
    Has anyone come accross this, or have any ideas?
    >
    Cheers.
    >

    Comment

    • TC

      #3
      Re: ASP date problems.

      I'm not really using anything to format the dates, the return from MySql is,
      as far as I know, the international format, so it's hh:mm:ss yyyy/mm/dd.
      For putting data in the grid I'm simply looking for the " " (Space char) and
      returning the right of the string.

      Yes, it is repeated over any browser or client connection so the issue has
      to be server side.

      The Web Server account? The user account that controls access to the web
      site?

      I'm a little new to this technology so any help would be very much
      appreciated.

      Cheers.



      "Claes Bergefall" <claes.bergefal l@nospam.nospam wrote in message
      news:%23tuevdZm IHA.5820@TK2MSF TNGP04.phx.gbl. ..
      Could be a number of reasons for this, the first that comes to mind is
      that the web server account has the wrong regional info.
      >
      I few questions:
      >
      What code are you using to format the dates?
      Are you using the <globalizatione lement in your web.config (and if so,
      how is it set)?
      Is the US format consistant across different browsers/machines?
      >
      /claes
      >
      >
      "TC" <tull@idcodewar e.co.ukwrote in message
      news:uIQNfLZmIH A.3512@TK2MSFTN GP03.phx.gbl...
      >Hi.
      >>
      >I have some ASP written in VB.net which is currently installed on a
      >customers server. The asp connects to a local MySql database and
      >retrieves data for the customers customers. If you see what I mean.
      >>
      >The problem is their server insists on showing dates in the US format.
      >The server has no other language installed than UK and all settings I can
      >find are UK.
      >>
      >My test server here, which as far as I can see is setup the same, shows
      >dates in the correct UK format.
      >>
      >Has anyone come accross this, or have any ideas?
      >>
      >Cheers.
      >>
      >
      >

      Comment

      • Patrice

        #4
        Re: ASP date problems.

        Usually the date format is controlled throught the globalization tag in the
        web.config file.

        Not sure about MySql but generally a DB system returns a date value not
        text. So this is still a date value client side. This is only when the text
        is written to text that this is converted to the text representation for the
        current country whatever it is...

        So try :
        http://msdn2.microsoft.com/en-us/lib...e0(VS.80).aspx (culture,
        uiCulture)


        "TC" <tull@idcodewar e.co.uka écrit dans le message de news:
        %23CN5EUamIHA.5 160@TK2MSFTNGP0 5.phx.gbl...
        I'm not really using anything to format the dates, the return from MySql
        is, as far as I know, the international format, so it's hh:mm:ss
        yyyy/mm/dd. For putting data in the grid I'm simply looking for the " "
        (Space char) and returning the right of the string.
        >
        Yes, it is repeated over any browser or client connection so the issue has
        to be server side.
        >
        The Web Server account? The user account that controls access to the web
        site?
        >
        I'm a little new to this technology so any help would be very much
        appreciated.
        >
        Cheers.
        >
        >
        >
        "Claes Bergefall" <claes.bergefal l@nospam.nospam wrote in message
        news:%23tuevdZm IHA.5820@TK2MSF TNGP04.phx.gbl. ..
        >Could be a number of reasons for this, the first that comes to mind is
        >that the web server account has the wrong regional info.
        >>
        >I few questions:
        >>
        >What code are you using to format the dates?
        >Are you using the <globalizatione lement in your web.config (and if so,
        >how is it set)?
        >Is the US format consistant across different browsers/machines?
        >>
        > /claes
        >>
        >>
        >"TC" <tull@idcodewar e.co.ukwrote in message
        >news:uIQNfLZmI HA.3512@TK2MSFT NGP03.phx.gbl.. .
        >>Hi.
        >>>
        >>I have some ASP written in VB.net which is currently installed on a
        >>customers server. The asp connects to a local MySql database and
        >>retrieves data for the customers customers. If you see what I mean.
        >>>
        >>The problem is their server insists on showing dates in the US format.
        >>The server has no other language installed than UK and all settings I
        >>can find are UK.
        >>>
        >>My test server here, which as far as I can see is setup the same, shows
        >>dates in the correct UK format.
        >>>
        >>Has anyone come accross this, or have any ideas?
        >>>
        >>Cheers.
        >>>
        >>
        >>
        >
        >

        Comment

        • TC

          #5
          Re: ASP date problems.

          I've had a look at the Web.Config file, but can't see anything in there for
          date formats or globalization, maybe this is the problem. What should I be
          looking for?

          Cheers.

          "Patrice" <http://www.chez.com/scribe/wrote in message
          news:uW2N6XamIH A.2504@TK2MSFTN GP05.phx.gbl...
          Usually the date format is controlled throught the globalization tag in
          the web.config file.
          >
          Not sure about MySql but generally a DB system returns a date value not
          text. So this is still a date value client side. This is only when the
          text is written to text that this is converted to the text representation
          for the current country whatever it is...
          >
          So try :
          http://msdn2.microsoft.com/en-us/lib...e0(VS.80).aspx (culture,
          uiCulture)
          >
          >
          "TC" <tull@idcodewar e.co.uka écrit dans le message de news:
          %23CN5EUamIHA.5 160@TK2MSFTNGP0 5.phx.gbl...
          >I'm not really using anything to format the dates, the return from MySql
          >is, as far as I know, the international format, so it's hh:mm:ss
          >yyyy/mm/dd. For putting data in the grid I'm simply looking for the " "
          >(Space char) and returning the right of the string.
          >>
          >Yes, it is repeated over any browser or client connection so the issue
          >has to be server side.
          >>
          >The Web Server account? The user account that controls access to the web
          >site?
          >>
          >I'm a little new to this technology so any help would be very much
          >appreciated.
          >>
          >Cheers.
          >>
          >>
          >>
          >"Claes Bergefall" <claes.bergefal l@nospam.nospam wrote in message
          >news:%23tuevdZ mIHA.5820@TK2MS FTNGP04.phx.gbl ...
          >>Could be a number of reasons for this, the first that comes to mind is
          >>that the web server account has the wrong regional info.
          >>>
          >>I few questions:
          >>>
          >>What code are you using to format the dates?
          >>Are you using the <globalizatione lement in your web.config (and if so,
          >>how is it set)?
          >>Is the US format consistant across different browsers/machines?
          >>>
          >> /claes
          >>>
          >>>
          >>"TC" <tull@idcodewar e.co.ukwrote in message
          >>news:uIQNfLZm IHA.3512@TK2MSF TNGP03.phx.gbl. ..
          >>>Hi.
          >>>>
          >>>I have some ASP written in VB.net which is currently installed on a
          >>>customers server. The asp connects to a local MySql database and
          >>>retrieves data for the customers customers. If you see what I mean.
          >>>>
          >>>The problem is their server insists on showing dates in the US format.
          >>>The server has no other language installed than UK and all settings I
          >>>can find are UK.
          >>>>
          >>>My test server here, which as far as I can see is setup the same, shows
          >>>dates in the correct UK format.
          >>>>
          >>>Has anyone come accross this, or have any ideas?
          >>>>
          >>>Cheers.
          >>>>
          >>>
          >>>
          >>
          >>
          >
          >

          Comment

          • TC

            #6
            Re: ASP date problems.

            I've just changed the code so I'm forcing the culture to en-NZ, there
            doesn't appear to be an en-UK setting. However NZ gives the same date
            format required. However, again it works on my server, not on the
            customers. I'm confused!



            "TC" <tull@idcodewar e.co.ukwrote in message
            news:uBBv6lamIH A.748@TK2MSFTNG P04.phx.gbl...
            I've had a look at the Web.Config file, but can't see anything in there
            for date formats or globalization, maybe this is the problem. What should
            I be looking for?
            >
            Cheers.
            >
            "Patrice" <http://www.chez.com/scribe/wrote in message
            news:uW2N6XamIH A.2504@TK2MSFTN GP05.phx.gbl...
            >Usually the date format is controlled throught the globalization tag in
            >the web.config file.
            >>
            >Not sure about MySql but generally a DB system returns a date value not
            >text. So this is still a date value client side. This is only when the
            >text is written to text that this is converted to the text representation
            >for the current country whatever it is...
            >>
            >So try :
            >http://msdn2.microsoft.com/en-us/lib...e0(VS.80).aspx (culture,
            >uiCulture)
            >>
            >>
            >"TC" <tull@idcodewar e.co.uka écrit dans le message de news:
            >%23CN5EUamIHA. 5160@TK2MSFTNGP 05.phx.gbl...
            >>I'm not really using anything to format the dates, the return from MySql
            >>is, as far as I know, the international format, so it's hh:mm:ss
            >>yyyy/mm/dd. For putting data in the grid I'm simply looking for the " "
            >>(Space char) and returning the right of the string.
            >>>
            >>Yes, it is repeated over any browser or client connection so the issue
            >>has to be server side.
            >>>
            >>The Web Server account? The user account that controls access to the
            >>web site?
            >>>
            >>I'm a little new to this technology so any help would be very much
            >>appreciated .
            >>>
            >>Cheers.
            >>>
            >>>
            >>>
            >>"Claes Bergefall" <claes.bergefal l@nospam.nospam wrote in message
            >>news:%23tuevd ZmIHA.5820@TK2M SFTNGP04.phx.gb l...
            >>>Could be a number of reasons for this, the first that comes to mind is
            >>>that the web server account has the wrong regional info.
            >>>>
            >>>I few questions:
            >>>>
            >>>What code are you using to format the dates?
            >>>Are you using the <globalizatione lement in your web.config (and if
            >>>so, how is it set)?
            >>>Is the US format consistant across different browsers/machines?
            >>>>
            >>> /claes
            >>>>
            >>>>
            >>>"TC" <tull@idcodewar e.co.ukwrote in message
            >>>news:uIQNfLZ mIHA.3512@TK2MS FTNGP03.phx.gbl ...
            >>>>Hi.
            >>>>>
            >>>>I have some ASP written in VB.net which is currently installed on a
            >>>>customers server. The asp connects to a local MySql database and
            >>>>retrieves data for the customers customers. If you see what I mean.
            >>>>>
            >>>>The problem is their server insists on showing dates in the US format.
            >>>>The server has no other language installed than UK and all settings I
            >>>>can find are UK.
            >>>>>
            >>>>My test server here, which as far as I can see is setup the same,
            >>>>shows dates in the correct UK format.
            >>>>>
            >>>>Has anyone come accross this, or have any ideas?
            >>>>>
            >>>>Cheers.
            >>>>>
            >>>>
            >>>>
            >>>
            >>>
            >>
            >>
            >
            >

            Comment

            • Claes Bergefall

              #7
              Re: ASP date problems.

              I'm not familiar with MySQL but I would expect the data to be stored using
              some kind of datetime data type and not as text. In SQL Server you would use
              smalldatetime or datetime to store a date and then work with the .NET
              DateTime datatype in your ASP.NET pages. Once you have a DateTime object you
              would use it's ToString method to format it in whatever way you want (see
              DateTime.ToStri ng)

              If it's really stored as text and you simply extract the right part of the
              string then I don't see any way for it to change format to US. If that is
              the case the problem is in the MySQL server. You need to verify what
              datatype is used and what it looks like. It would help if you could show the
              code you're using to get the date from the database.

              The <globalizationt ag in web.config allows the web server to provide
              formating according to the user's preferences. It gets this information from
              the client browser (e.g. in IE you can specify what language you prefer in
              the options). However, this only works if you're using real date types, so
              figure out the things above first and you can deal with this step later
              (it's entirely optional anyway)

              As for the account thing; the process that hosts your ASP.NET application on
              the web server (I'm guessing IIS?) runs under it's own account called ASPNET
              (or something like that). That account has it's own settings regarding
              security, culture info etc. If the machine was installed using a UK version
              on Windows it most likely has the correct settings already.

              /claes

              "TC" <tull@idcodewar e.co.ukwrote in message
              news:%23CN5EUam IHA.5160@TK2MSF TNGP05.phx.gbl. ..
              I'm not really using anything to format the dates, the return from MySql
              is, as far as I know, the international format, so it's hh:mm:ss
              yyyy/mm/dd. For putting data in the grid I'm simply looking for the " "
              (Space char) and returning the right of the string.
              >
              Yes, it is repeated over any browser or client connection so the issue has
              to be server side.
              >
              The Web Server account? The user account that controls access to the web
              site?
              >
              I'm a little new to this technology so any help would be very much
              appreciated.
              >
              Cheers.
              >
              >
              >
              "Claes Bergefall" <claes.bergefal l@nospam.nospam wrote in message
              news:%23tuevdZm IHA.5820@TK2MSF TNGP04.phx.gbl. ..
              >Could be a number of reasons for this, the first that comes to mind is
              >that the web server account has the wrong regional info.
              >>
              >I few questions:
              >>
              >What code are you using to format the dates?
              >Are you using the <globalizatione lement in your web.config (and if so,
              >how is it set)?
              >Is the US format consistant across different browsers/machines?
              >>
              > /claes
              >>
              >>
              >"TC" <tull@idcodewar e.co.ukwrote in message
              >news:uIQNfLZmI HA.3512@TK2MSFT NGP03.phx.gbl.. .
              >>Hi.
              >>>
              >>I have some ASP written in VB.net which is currently installed on a
              >>customers server. The asp connects to a local MySql database and
              >>retrieves data for the customers customers. If you see what I mean.
              >>>
              >>The problem is their server insists on showing dates in the US format.
              >>The server has no other language installed than UK and all settings I
              >>can find are UK.
              >>>
              >>My test server here, which as far as I can see is setup the same, shows
              >>dates in the correct UK format.
              >>>
              >>Has anyone come accross this, or have any ideas?
              >>>
              >>Cheers.
              >>>
              >>
              >>
              >
              >

              Comment

              • TC

                #8
                Re: ASP date problems.

                No, the date is stored as a date, MySql basically uses 00:00:00 yyyy/MM/dd
                as standard. So I've been pulling the date time from the database and
                formatting text simply to remove anything left of the space char. So the
                date format is already wrong before I do any formating.

                I have tried forcing the culture, forcing a Format("dd/MM/yyyy", dte) but it
                still shows US format of M/d/yyyy.

                I'm beggining to think there is a problem with this server!

                "Claes Bergefall" <claes.bergefal l@nospam.nospam wrote in message
                news:u1OBoOimIH A.5160@TK2MSFTN GP05.phx.gbl...
                I'm not familiar with MySQL but I would expect the data to be stored using
                some kind of datetime data type and not as text. In SQL Server you would
                use smalldatetime or datetime to store a date and then work with the .NET
                DateTime datatype in your ASP.NET pages. Once you have a DateTime object
                you would use it's ToString method to format it in whatever way you want
                (see DateTime.ToStri ng)
                >
                If it's really stored as text and you simply extract the right part of the
                string then I don't see any way for it to change format to US. If that is
                the case the problem is in the MySQL server. You need to verify what
                datatype is used and what it looks like. It would help if you could show
                the code you're using to get the date from the database.
                >
                The <globalizationt ag in web.config allows the web server to provide
                formating according to the user's preferences. It gets this information
                from the client browser (e.g. in IE you can specify what language you
                prefer in the options). However, this only works if you're using real date
                types, so figure out the things above first and you can deal with this
                step later (it's entirely optional anyway)
                >
                As for the account thing; the process that hosts your ASP.NET application
                on the web server (I'm guessing IIS?) runs under it's own account called
                ASPNET (or something like that). That account has it's own settings
                regarding security, culture info etc. If the machine was installed using a
                UK version on Windows it most likely has the correct settings already.
                >
                /claes
                >
                "TC" <tull@idcodewar e.co.ukwrote in message
                news:%23CN5EUam IHA.5160@TK2MSF TNGP05.phx.gbl. ..
                >I'm not really using anything to format the dates, the return from MySql
                >is, as far as I know, the international format, so it's hh:mm:ss
                >yyyy/mm/dd. For putting data in the grid I'm simply looking for the " "
                >(Space char) and returning the right of the string.
                >>
                >Yes, it is repeated over any browser or client connection so the issue
                >has to be server side.
                >>
                >The Web Server account? The user account that controls access to the web
                >site?
                >>
                >I'm a little new to this technology so any help would be very much
                >appreciated.
                >>
                >Cheers.
                >>
                >>
                >>
                >"Claes Bergefall" <claes.bergefal l@nospam.nospam wrote in message
                >news:%23tuevdZ mIHA.5820@TK2MS FTNGP04.phx.gbl ...
                >>Could be a number of reasons for this, the first that comes to mind is
                >>that the web server account has the wrong regional info.
                >>>
                >>I few questions:
                >>>
                >>What code are you using to format the dates?
                >>Are you using the <globalizatione lement in your web.config (and if so,
                >>how is it set)?
                >>Is the US format consistant across different browsers/machines?
                >>>
                >> /claes
                >>>
                >>>
                >>"TC" <tull@idcodewar e.co.ukwrote in message
                >>news:uIQNfLZm IHA.3512@TK2MSF TNGP03.phx.gbl. ..
                >>>Hi.
                >>>>
                >>>I have some ASP written in VB.net which is currently installed on a
                >>>customers server. The asp connects to a local MySql database and
                >>>retrieves data for the customers customers. If you see what I mean.
                >>>>
                >>>The problem is their server insists on showing dates in the US format.
                >>>The server has no other language installed than UK and all settings I
                >>>can find are UK.
                >>>>
                >>>My test server here, which as far as I can see is setup the same, shows
                >>>dates in the correct UK format.
                >>>>
                >>>Has anyone come accross this, or have any ideas?
                >>>>
                >>>Cheers.
                >>>>
                >>>
                >>>
                >>
                >>
                >
                >

                Comment

                • Andrew Morton

                  #9
                  Re: ASP date problems.

                  TC wrote:
                  I've just changed the code so I'm forcing the culture to en-NZ, there
                  doesn't appear to be an en-UK setting.
                  It would be en-gb, not en-uk.

                  For an Access db, you can specify the locale in the connection string, e.g.:

                  "Driver={Micros oft Access Driver (*.mdb)};Dbq=C: \mydatabase.mdb ;Locale
                  Identifier=2057 ;Uid=Admin;Pwd= ;"

                  ....maybe you can find similar for mySql.

                  Andrew


                  Comment

                  • Claes Bergefall

                    #10
                    Re: ASP date problems.


                    "TC" <tull@idcodewar e.co.ukwrote in message
                    news:OPjWEAjmIH A.5692@TK2MSFTN GP03.phx.gbl...
                    No, the date is stored as a date, MySql basically uses 00:00:00 yyyy/MM/dd
                    as standard. So I've been pulling the date time from the database and
                    formatting text simply to remove anything left of the space char. So the
                    date format is already wrong before I do any formating.
                    This doesn't make sense. If the date is stored in the database using a real
                    date type then where are you getting the string 00:00:00 yyyy/MM/dd from?
                    Who created that string? What kind of data type do you have on the .NET side
                    of things?

                    I looked into MySQL a bit more and I noticed they have an ADO.NET library
                    with a MySqlDateTime type. Is this what you're using? If so you should be
                    able to get a real .NET DateTime object using the MySqlDateTime.G etDateTime
                    method. Once you have that it's a simple thing to format it the way you
                    want.

                    It would help if you could show us the code you're using to get the dates
                    from the database and also how you're formatting the output.

                    >I have tried forcing the culture, forcing a Format("dd/MM/yyyy", dte) but
                    >it still shows US format of M/d/yyyy.
                    Is this .NET code? What's the datatype of the dte parameter?

                    >I'm beggining to think there is a problem with this server!
                    Well, it looks like the server is not setup exactly the same way as your
                    test server. On the other hand I also think there is a problem with your
                    code in the way it handles dates.


                    /claes


                    Comment

                    Working...