stored procedures - How do I change the format of my date in SQL Server -
I am using SQL Server 2008 R2 and I have a table that has the start date in my table, Looks like,
1977-10-17 00: 00: 00.000
How do I change those values to represent 10-17-1977? Apart from this, if date is 19 00-01-01 00: 00: 00.000 then I want to convert it to zero value. Are there any commands or stored procedures for these types of changes?
Thanks Nick
You probably use later to get your format Like:
Convert from MyTable (varchar (10), MyColumn, 110);
Here we are converting your data into a character value, but with a special date style (style 110).
Your tap issue can be sorted by switch or with the function:
Select nullif (MyColumn, '19010101') from MyTable; Select case when MyColumn = '19010101' then tap MyTable and end MyColumn;
Note that I'm assuming MyColumn
is stored in the form of a day-time or similar datatype if not, then you cast
They can do according to the above documents.
Feel free to combine tasks like:
select convert (varchar (10), nullif (MyColumn, '19010101'), 110) From MyTable;
Comments
Post a Comment