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. how to save only time in database field

how to save only time in database field

Scheduled Pinned Locked Moved Database
databasesql-serversysadmintutorial
3 Posts 3 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.
  • F Offline
    F Offline
    findtango
    wrote on last edited by
    #1

    hi i want my sql server database save the data like 12:12:12 PM..Database must contain only time value nt default date value. currently it saved data like 1/1/1900 12:12:12 PM and i want it save as 12:12:12 PM plz give me solution to do this.

    P A 2 Replies Last reply
    0
    • F findtango

      hi i want my sql server database save the data like 12:12:12 PM..Database must contain only time value nt default date value. currently it saved data like 1/1/1900 12:12:12 PM and i want it save as 12:12:12 PM plz give me solution to do this.

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      A datetime field stores a whole date and time. You can't store just a time. There are functions in T-SQL for extracting time-specific information from a datetime value.

      Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

      1 Reply Last reply
      0
      • F findtango

        hi i want my sql server database save the data like 12:12:12 PM..Database must contain only time value nt default date value. currently it saved data like 1/1/1900 12:12:12 PM and i want it save as 12:12:12 PM plz give me solution to do this.

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

        Hey, Unfortunately you cannot save the dateTime column without date. However you can extract them using the convert function in SQl Server. e.g: select convert(varchar,DateColumn,108) from MyDateTest99 The following table gives you the details of which digit sequence to use: 0 or 100 mon dd yyyy hh:miAM (or PM) 101 mm/dd/yy 102 yy.mm.dd 103 dd/mm/yy 104 dd.mm.yy 105 dd-mm-yy 106 dd mon yy 107 Mon dd, yy 108 hh:mm:ss 9 or 109 mon dd yyyy hh:mi:ss:mmmAM (or PM) 110 mm-dd-yy 111 yy/mm/dd 112 yymmdd 13 or 113 dd mon yyyy hh:mm:ss:mmm(24h) 114 hh:mi:ss:mmm(24h) 20 or 120 yyyy-mm-dd hh:mi:ss(24h) 21 or 121 yyyy-mm-dd hh:mi:ss.mmm(24h) 126 yyyy-mm-dd Thh:mm:ss.mmm(no spaces) 130 dd mon yyyy hh:mi:ss:mmmAM 131 dd/mm/yy hh:mi:ss:mmmAM Hope that this helps... Regards, Ali

        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