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. DateTime Problem

DateTime Problem

Scheduled Pinned Locked Moved Database
helpdatabase
4 Posts 4 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.
  • M Offline
    M Offline
    Mohammed Elkholy
    wrote on last edited by
    #1

    hi i have a problem here i have a column in database the data type is DateTime i insert into this column Time only LIKE " 09 : 00 AM " but after i insert data it stores in table date with the time i entered the problem is i want to select the data from this column as Time Only i try this select convert(smalldatetime ,ExamTime,108) but i back by the date also how can solve my problem thnx 4 help

    MD_NADA

    B K 2 Replies Last reply
    0
    • M Mohammed Elkholy

      hi i have a problem here i have a column in database the data type is DateTime i insert into this column Time only LIKE " 09 : 00 AM " but after i insert data it stores in table date with the time i entered the problem is i want to select the data from this column as Time Only i try this select convert(smalldatetime ,ExamTime,108) but i back by the date also how can solve my problem thnx 4 help

      MD_NADA

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      did you try to convert in varchar type? select convert(varchar,ExamTime,108)


      I Love SQL

      S 1 Reply Last reply
      0
      • M Mohammed Elkholy

        hi i have a problem here i have a column in database the data type is DateTime i insert into this column Time only LIKE " 09 : 00 AM " but after i insert data it stores in table date with the time i entered the problem is i want to select the data from this column as Time Only i try this select convert(smalldatetime ,ExamTime,108) but i back by the date also how can solve my problem thnx 4 help

        MD_NADA

        K Offline
        K Offline
        Kschuler
        wrote on last edited by
        #3

        Another option would be to store the time as a number, and when you retrieve it from your database, you can format it in your own way. For example, I store time fields as 6 digit numbers. The first two digits for the hour (military time) the second two digits as minutes, and the last two digits as seconds. So when I store them to my data base I only have to take the datetime object and do this: myDataBaseRow("myTimeColumn") = objDateTime.ToString("HHmmss") I know this isn't what you asked for, but I thought another view point might be helpful.

        1 Reply Last reply
        0
        • B Blue_Boy

          did you try to convert in varchar type? select convert(varchar,ExamTime,108)


          I Love SQL

          S Offline
          S Offline
          sidbaruah
          wrote on last edited by
          #4

          One quick question I am using this replace(convert(varchar(16),cast([WEEK] as datetime),111),' ','-') How does it differ from

          Blue_Boy wrote:

          select convert(varchar,ExamTime,108)

          ??

          I was born dumb!! :laugh:Programming made me laugh:laugh:!!! --sid--

          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