Assuming that you are using SQL Server (which I think you are), it sounds like you're using the datetime
data type:
datetime
represents an instant in time. Internally, datetime
consists of a pair of integers:
- The first measures the offset in days from the epoch. An epoch is the zero point of a calendar system, which for SQL Server
1 January 1900 00:00:00.000
.
- The second is the [positive] offset since start of day, in milliseconds.
How that internal representation is represented visually is entirely up to you, though SQL Server has a [configurable] default conversion pattern.
If you are accessing your SQL programmatically, say from C#, the API automatically maps the SQL Server datetime
datatype to your languages equivalent type (System.Datetime
for C#). The issue is present: it is your responsibility to format it visually or textually.
If you want to see only the date component. You can format it in T-SQL using the convert()
/cast()
function: convert(varchar(32),{some-datetime-expression},116)
will convert the {some-datetime-expression}
to the format dd mmm yyyy
. Lots of other options.
Further assuming that you are using a recent-ish version of SQL Server, if you just want to deal with dates, change your schema to use the date
datatype instead of datetime
.