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. Date-Time Format in C# and SQL Server

Date-Time Format in C# and SQL Server

Scheduled Pinned Locked Moved ASP.NET
csharpdatabasehelpasp-netsql-server
3 Posts 3 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.
  • Z Offline
    Z Offline
    Zeyad Jalil
    wrote on last edited by
    #1

    hi all, I use sql server 2005 and C#(asp.net) to build a library system (web site), but my problem is.. i can insert a row into database at datetime format MM/dd/yyyy, but if my server date format changed to any format my web site is stop work and do an exception ..( the conversion of a char data type to a datetime data type resulted in an out-of-range datetime value). can u help me please,,, thanks all

    S N 2 Replies Last reply
    0
    • Z Zeyad Jalil

      hi all, I use sql server 2005 and C#(asp.net) to build a library system (web site), but my problem is.. i can insert a row into database at datetime format MM/dd/yyyy, but if my server date format changed to any format my web site is stop work and do an exception ..( the conversion of a char data type to a datetime data type resulted in an out-of-range datetime value). can u help me please,,, thanks all

      S Offline
      S Offline
      SeMartens
      wrote on last edited by
      #2

      Hi, could you post the code how you are trying to insert the new row? I guess the sql-server is expecting a datetime-row and you try to store the date as string. Regards Sebastian

      It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

      1 Reply Last reply
      0
      • Z Zeyad Jalil

        hi all, I use sql server 2005 and C#(asp.net) to build a library system (web site), but my problem is.. i can insert a row into database at datetime format MM/dd/yyyy, but if my server date format changed to any format my web site is stop work and do an exception ..( the conversion of a char data type to a datetime data type resulted in an out-of-range datetime value). can u help me please,,, thanks all

        N Offline
        N Offline
        Nishant Singh
        wrote on last edited by
        #3

        Try to Change the DateFormat to MM/dd/yyyy before inserting into database Like this

        DateTime.Today.ToString("dd-MMM-yyyy")

        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