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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. DateTime saving problem from C# application..

DateTime saving problem from C# application..

Scheduled Pinned Locked Moved C#
databasecsharphelpsql-serversysadmin
3 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.
  • S Offline
    S Offline
    shaz jazz
    wrote on last edited by
    #1

    Hi! I have some problem relating saving datetime variable in SQL Server from C#.net application. i use Datetime.ToShortDateString() while sending parameter to Database. now the format of resulting string depends upon the regional settings of windows and SQL server takes M/dd/yyyy format or ISO format yyyymmdd. I want my application to be independent of regional settings. so i want whatever the regional setting is i should send to DB after converting to M/dd/yyyy format. For this purpose i wanted to override DateTime.ToShortDateString() but DateTime is a sealed class. So what should i Do??? any suggestions??

    May God help u solv ur problems as well,thx in advance!!

    G P 2 Replies Last reply
    0
    • S shaz jazz

      Hi! I have some problem relating saving datetime variable in SQL Server from C#.net application. i use Datetime.ToShortDateString() while sending parameter to Database. now the format of resulting string depends upon the regional settings of windows and SQL server takes M/dd/yyyy format or ISO format yyyymmdd. I want my application to be independent of regional settings. so i want whatever the regional setting is i should send to DB after converting to M/dd/yyyy format. For this purpose i wanted to override DateTime.ToShortDateString() but DateTime is a sealed class. So what should i Do??? any suggestions??

      May God help u solv ur problems as well,thx in advance!!

      G Offline
      G Offline
      Giorgi Dalakishvili
      wrote on last edited by
      #2

      Call ToString() method and pass the format you wish. You may use CultureInfo..::.InvariantCulture Property[^]

      #region signature my articles #endregion

      1 Reply Last reply
      0
      • S shaz jazz

        Hi! I have some problem relating saving datetime variable in SQL Server from C#.net application. i use Datetime.ToShortDateString() while sending parameter to Database. now the format of resulting string depends upon the regional settings of windows and SQL server takes M/dd/yyyy format or ISO format yyyymmdd. I want my application to be independent of regional settings. so i want whatever the regional setting is i should send to DB after converting to M/dd/yyyy format. For this purpose i wanted to override DateTime.ToShortDateString() but DateTime is a sealed class. So what should i Do??? any suggestions??

        May God help u solv ur problems as well,thx in advance!!

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        Don't use a string, use a parameter.

        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