depends what the data type of the destination field is, if it is datetime then you can only have the full date-time, if it is a varchar then you can use convert to format the date in the format you want.
You should be aware that in order to do any calculations on a varchar you need to convert them back to date-time
There are ways to extract Date only and Time only from Getdate(), but MS SQL Server will only support DATETIME and SMALLDATETIME for datatypes. So even if you use your PHP to insert this data, the field within SQL Server will be storing it in DATETIME format. There is no TIME datatype like in Oracle. So, here is sample code for the two extractions in Varchar format:
select convert(varchar(10),getdate(),101) as [date]
select convert(varchar(8),getdate(),108) as [time]
Hi MeanGreen!
Can you show me please these ways of extracting only Date and Time part of GetDate()! (and inserting it in Datetime-column).
(I know that there is no Time-format and for me Datetime-format is just OK! )
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.