Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Compare Validators - Date Problem

Compare Validators - Date Problem

Scheduled Pinned Locked Moved ASP.NET
helptutorialquestion
8 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    just4ulove7
    wrote on last edited by
    #1

    Hi,, I am using Compare validators to compare two dates. One of them is as below. Now I need to enter dates in dd/MM/yyyy format. But the Compare validator takes the default date format as MM/dd/yyyy. So if I have two dates as 5/7/2005 2/8/2005 the above date proves to be greater than the below date, as it compares mm/dd/yyyy format, and my validation gets wrong. Can anyone tell me how to change the Datechecking format of the validator? Or any other options... Thanks

    G 1 Reply Last reply
    0
    • J just4ulove7

      Hi,, I am using Compare validators to compare two dates. One of them is as below. Now I need to enter dates in dd/MM/yyyy format. But the Compare validator takes the default date format as MM/dd/yyyy. So if I have two dates as 5/7/2005 2/8/2005 the above date proves to be greater than the below date, as it compares mm/dd/yyyy format, and my validation gets wrong. Can anyone tell me how to change the Datechecking format of the validator? Or any other options... Thanks

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Create a CultureInfo for your locale and put it in Thread.CurrentCulture to alter the date format. Example for settings swedish culture: Thread.CurrentCulture = new CultureInfo(1053); --- b { font-weight: normal; }

      J 1 Reply Last reply
      0
      • G Guffa

        Create a CultureInfo for your locale and put it in Thread.CurrentCulture to alter the date format. Example for settings swedish culture: Thread.CurrentCulture = new CultureInfo(1053); --- b { font-weight: normal; }

        J Offline
        J Offline
        just4ulove7
        wrote on last edited by
        #3

        Sorry didnt get u. Where should I code for Thread.CurrentCulture? Thanks

        G 1 Reply Last reply
        0
        • J just4ulove7

          Sorry didnt get u. Where should I code for Thread.CurrentCulture? Thanks

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          Make sure that it happens before the validation. In global.asax might be a good place. --- b { font-weight: normal; }

          J 1 Reply Last reply
          0
          • G Guffa

            Make sure that it happens before the validation. In global.asax might be a good place. --- b { font-weight: normal; }

            J Offline
            J Offline
            just4ulove7
            wrote on last edited by
            #5

            Thanks a lot. It worked out... I found another option too To put culture="en-GB" uiCulture="en-GB" in Web.config, Globalization section. Thanks

            M 1 Reply Last reply
            0
            • J just4ulove7

              Thanks a lot. It worked out... I found another option too To put culture="en-GB" uiCulture="en-GB" in Web.config, Globalization section. Thanks

              M Offline
              M Offline
              minhpc_bk
              wrote on last edited by
              #6

              Hi there, In addition to placing the settings in the web.config file and it will affect the entire application, you can also set those properties in the Page directive for a specific web page.

              J 1 Reply Last reply
              0
              • M minhpc_bk

                Hi there, In addition to placing the settings in the web.config file and it will affect the entire application, you can also set those properties in the Page directive for a specific web page.

                J Offline
                J Offline
                just4ulove7
                wrote on last edited by
                #7

                How to do that? Also let me know ... If I have specified a setting in web.config for culture, Is it possible to specify another date format in a particular control. I tried doing this but it throws an error. Like I have specified "dd/MM/yyyy" in web.config. I want a particular dateformat in a variable to be in MM/dd/yyyy format, so i just used .ToString("MM/dd/yyyy",new CultureInfo("en-GB")) but it gave an error... Just wanted to know this... Thanks...

                M 1 Reply Last reply
                0
                • J just4ulove7

                  How to do that? Also let me know ... If I have specified a setting in web.config for culture, Is it possible to specify another date format in a particular control. I tried doing this but it throws an error. Like I have specified "dd/MM/yyyy" in web.config. I want a particular dateformat in a variable to be in MM/dd/yyyy format, so i just used .ToString("MM/dd/yyyy",new CultureInfo("en-GB")) but it gave an error... Just wanted to know this... Thanks...

                  M Offline
                  M Offline
                  minhpc_bk
                  wrote on last edited by
                  #8

                  It looks something like:

                  <%@ Page UICulture="en" Culture="en-GB"...%>

                  At runtime, you can format the value of the DateTime type for a specific culture, you can take a look at here[^] for more information. Since you didn't say what is the error, what your failure code looks like, so I have no idea why.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups