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. how to convert string value to datetime accoring to current culture

how to convert string value to datetime accoring to current culture

Scheduled Pinned Locked Moved ASP.NET
databasehelptutorial
5 Posts 2 Posters 0 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.
  • M Offline
    M Offline
    mr_muskurahat
    wrote on last edited by
    #1

    i have two string values "MM/dd/yyyy" & "dd/MM/yyyy" when i assign to sql parameters if the culture accepts MM/dd/yyyy then it gives error on dd/MM/yyyy cannot convert string to datetime. is there any way to convert string to datetime according to current culure i have tried textbox.text.tostring(system.threading.thread.currentthread.currentculutre) but no use datetime.parse(string) not do anything.... and i cannot use convert.todatetime function because these dates may b empty.

    umerumerumer

    K 1 Reply Last reply
    0
    • M mr_muskurahat

      i have two string values "MM/dd/yyyy" & "dd/MM/yyyy" when i assign to sql parameters if the culture accepts MM/dd/yyyy then it gives error on dd/MM/yyyy cannot convert string to datetime. is there any way to convert string to datetime according to current culure i have tried textbox.text.tostring(system.threading.thread.currentthread.currentculutre) but no use datetime.parse(string) not do anything.... and i cannot use convert.todatetime function because these dates may b empty.

      umerumerumer

      K Offline
      K Offline
      keyur satyadev
      wrote on last edited by
      #2

      you have to change the format of string using following way.this is for binding the date with textbox.in your case you have to pass the date in following way to your sql parameter. eg. ]]> Regards, Keyur Satyadev

      M 1 Reply Last reply
      0
      • K keyur satyadev

        you have to change the format of string using following way.this is for binding the date with textbox.in your case you have to pass the date in following way to your sql parameter. eg. ]]> Regards, Keyur Satyadev

        M Offline
        M Offline
        mr_muskurahat
        wrote on last edited by
        #3

        but i want to do it after picking it from the textbox is there any way to convert string accoring to current system date time format

        umerumerumer

        M 1 Reply Last reply
        0
        • M mr_muskurahat

          but i want to do it after picking it from the textbox is there any way to convert string accoring to current system date time format

          umerumerumer

          M Offline
          M Offline
          mr_muskurahat
          wrote on last edited by
          #4

          actually right now i am facing problem like DateTime.Today.Date.ToString(System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern) it is not picking my system datetime format :( always use MM/dd/yyyy even i am using dd/MM/yyyy

          umerumerumer

          K 1 Reply Last reply
          0
          • M mr_muskurahat

            actually right now i am facing problem like DateTime.Today.Date.ToString(System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern) it is not picking my system datetime format :( always use MM/dd/yyyy even i am using dd/MM/yyyy

            umerumerumer

            K Offline
            K Offline
            keyur satyadev
            wrote on last edited by
            #5

            use the following code System.DateTime.Today.ToString("dd/MM/yyyy"); it will be work.

            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