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 datetime to certain format

Convert datetime to certain format

Scheduled Pinned Locked Moved Database
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.
  • V Offline
    V Offline
    vanikanc
    wrote on last edited by
    #1

    Hello All, I need to convert this value of datetime 2012-09-16T20:08:30Z to this format "mmddyy". I tried select convert(char(10),'2012-09-16T20:08:30Z',101) - but this did not work. Is there any other method to try before trying to write a whole bunch of casts, replaces!

    I 1 Reply Last reply
    0
    • V vanikanc

      Hello All, I need to convert this value of datetime 2012-09-16T20:08:30Z to this format "mmddyy". I tried select convert(char(10),'2012-09-16T20:08:30Z',101) - but this did not work. Is there any other method to try before trying to write a whole bunch of casts, replaces!

      I Offline
      I Offline
      Ingo
      wrote on last edited by
      #2

      vanikanc wrote:

      I need to convert this value of datetime
      2012-09-16T20:08:30Z to this format "mmddyy".

      Doesn't seem a valid datetime format to me As a string-function use:

      SELECT LEFT('2012-09-16T20:08:30Z', 10) ...

      With values in datetime-format:

      SELECT CONVERT(DATE,@datetime)

      ------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.

      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