SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 prefix added to date filed
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Blessed1978
Starting Member

48 Posts

Posted - 03/06/2014 :  21:22:09  Show Profile  Reply with Quote
I would like to add 9999 to a column in my sql 2012 database named modified date which is in the format yyyy-mm-dd hh:mm:ss
so it should look like '9999-2013-02-01:23:00:000'

please advise

khtan
In (Som, Ni, Yak)

Singapore
17584 Posts

Posted - 03/06/2014 :  21:28:30  Show Profile  Reply with Quote
you mean update it back to the table ? what is the data type for that column ?


KH
Time is always against us

Go to Top of Page

Blessed1978
Starting Member

48 Posts

Posted - 03/06/2014 :  22:16:13  Show Profile  Reply with Quote
the data type for modified date is datetime I just want to ad 9999-in front of the modified date 9999-modified_date

Edited by - Blessed1978 on 03/06/2014 22:18:03
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
17584 Posts

Posted - 03/06/2014 :  22:30:42  Show Profile  Reply with Quote
if you want to update the datetime value back in the table, that is not possible. It will be an invalid date.

if you are just want to show that during retrieving of the data, it is possible with
SELECT '9999-' + CONVERT(VARCHAR(30), modified_date, 121)



KH
Time is always against us

Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
17584 Posts

Posted - 03/06/2014 :  22:32:25  Show Profile  Reply with Quote
quote:
Originally posted by Blessed1978

I would like to add 9999 to a column in my sql 2012 database named modified date which is in the format yyyy-mm-dd hh:mm:ss
so it should look like '9999-2013-02-01:23:00:000'

please advise



For you information, the datetime is not stored in the table in that format. It is stored in binary format. That is just how your query window present the date time to you


KH
Time is always against us

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000