I want to store the office starting time etc in my database.
The time I want to store is like 09:15 AM
or 1:15PM
etc
My question is what is the best way to store it?
For the time being I am using int
in SQL Server.
And I am storing the data like 0915, 1605, 2305
(maybe I can use some sort of constraints too)
Is there any better and good way to do it.
Any help is appreciated.
If you are using SQL 2008 or newer, you can use TIME Datatype to store only time. What is the equivalent of TIME for sql server 2005 ?
The SQL Server TIME data type defines a time of a day based on 24-hour clock. The syntax of the TIME data type is as follows: TIME [ (fractional second scale) ] Code language: SQL (Structured Query Language) (sql) The fractional second scale specifies the number of digits for the fractional part of the seconds.
Summary: in this tutorial, you will learn how to store the time of a day in the database by using SQL Server TIME data type. The SQL Server TIME data type defines a time of a day based on 24-hour clock. The syntax of the TIME data type is as follows: The fractional second scale specifies the number of digits for the fractional part of the seconds.
A data type is an attribute that specifies the type of data that these objects can store. It can be an integer, character string, monetary, date and time, and so on. SQL Server provides a list of data types that define all types of data that you can use e.g., defining a column or declaring a variable.
If you are using SQL 2008 or newer, you can use TIME Datatype to store only time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With