sql server - SQL change DATEADD data type -



sql server - SQL change DATEADD data type -

i trying round time column quarters, searched forum , found nice code:

select dateadd(minute, datediff(minute, 0, getdate()) / 15 * 15, 0)

the problem gives me time timestamp column, date 1900-01-01, while want time. can't find how this.

you didn't specify version of sql server using.

since sql server 2008 have had time info type (http://msdn.microsoft.com/en-us/library/bb677243(v=sql.100).aspx).

select dateadd(mi, datediff(mi, 0, getdate()) / 15 * 15, 0) original_value , convert(time, dateadd(mi, datediff(mi, 0, getdate()) / 15 * 15, 0)) sql_2008_onwards , convert(char(10), dateadd(mi, datediff(mi, 0, getdate()) / 15 * 15, 0), 108) pre_sql_2008

with lastly option, final value still piece of text. ideally should convert in datetime value (convert(datetime, <rest of code>))

sql sql-server

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -