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. Database & SysAdmin
  3. Database
  4. converting char to datatime

converting char to datatime

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

    in my source table i have '1530' as char data type which is actually a time (HHMM) in my destination table the column is datetime. how could i convert '1530' and insert into destination table of type datetime. please help

    A 1 Reply Last reply
    0
    • U uglyeyes

      in my source table i have '1530' as char data type which is actually a time (HHMM) in my destination table the column is datetime. how could i convert '1530' and insert into destination table of type datetime. please help

      A Offline
      A Offline
      Ali Rashid
      wrote on last edited by
      #2

      Hey there! It is a bit hard to convert it to dateTime from just 24hrs Time format. From the little knowledge you have, you could play around with the following syntax but I am sure that it won't return you the proper result. Syntax: convert(varchar(24),cast(1530 as datetime),8) It would be wise to just do it on the front end if you are using it. In C#, you can achieve this by: DateTime _dteDateTime = Convert.ToDateTime("1530").ToString("hh:mm"); If you are using VB.Net, I think the syntax was: FORMAT(Node, "yyyy-mm-dd") Hope that this helps. ------------------------------------------------------------------------ If there was no SQL, there would be no sequels to programming.

      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