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