I have a SQL table that has a CreationDate field.
I have getdate()
in the computed column specification formula.
I would like to know how to get just the date portion, that is, '2012-08-24' instead of '2012-08-24 10:45:17.740'.
If you want to get a day from a date in a table, use the SQL Server DAY() function. This function takes only one argument – the date. This can be a date or date and time data type. (In our example, the column VisitDate is of the date data type.)
In order to get the date from the timestamp, you can use DATE() function from MySQL.
If you are using SQL Server 2008 or later
select convert(date, getdate())
Otherwise
select convert(varchar(10), getdate(),120)
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