Hi,
I have a table column Plaerdob witch have diff date type like
1- 1-jan-1987.
2- 01/01/1987
3- 01-jan-1987.
Here i want to update all my dates format of 2 and 3 into 1.
Can it be possible? if yes then how?
Pls help.
Thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Wim SturkenboomPosted Sep 18, 2014, 7:59 AM
The (partial) solution: just change the type of your date column to datetime2. On my system it converts all the example dates to 1987-01-01.
Notes:
- If you store a date in sql server, store it with the correct type.
- Once you have the correct type, there are ways in C#/VB (and to my knowledge in SQL, but I have never used it) to display in the desired format. So don't worry about that.
C# examples:string strDate = DateTime.Now.ToString("yyyyMMdd");
or
string strDate = DateTime.Now.ToString("d-MMM-yyyy");
The last one gives the output that you want.