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. Database & SysAdmin
  3. Database
  4. convert varchar to date format

convert varchar to date format

Scheduled Pinned Locked Moved Database
databasehelp
2 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.
  • C Offline
    C Offline
    ciacia
    wrote on last edited by
    #1

    Hello , I want to wirte a sql statment which converts varchar into date (mm/dd/yyyy) format. please help thanks

    M 1 Reply Last reply
    0
    • C ciacia

      Hello , I want to wirte a sql statment which converts varchar into date (mm/dd/yyyy) format. please help thanks

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      CAST( @var AS datetime ) works well for dates in the current DATEFORMAT or using ISO 8601 format (yyyyMMdd). The DATEFORMAT defaults to the appropriate format for the current LANGUAGE (really a locale). The default value for LANGUAGE comes from the user's login, which in turn gets it (at creation time) from the server's default language option. Otherwise look at CONVERT. As a best practice you should pass dates and indeed all other user-supplied data using parameterized queries, for which see the documentation for the provider you're using. That passes the data using a well-understood datatype, rather than parsing the information multiple times.

      Stability. What an interesting concept. -- Chris Maunder

      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