We can format the sql server 'datetime' field into a specific date time format. SQL Server provides this functionality through an inbuilt function called CONVERT(). For Example you can get the date format in dd/mm/yy by using the following query.
Select Convert(Varchar(10),GetDate(),3) from your_table_name.
Look at the third integer parameter you are passing(i.e. 3), which does the formating part.
Following are the values and thier corresponding formats :
1----------------- mm/dd/yy
2-----------------yy.mm.dd
3-----------------dd/mm/yy
4-----------------dd.mm.yy
(And so on. Other format numbers range from 100-114, 120,121,126,130,131) .Try it n see the results yourself.....enjoy
Have a nice day... 'N happy Coding :)
No comments:
Post a Comment