Saturday, February 18, 2012

Fetch / Get Current Date from SQL Server in a specific format

Hi All,
      Working on Saturday is really a pain...Phew...!!!!...

I came across a requirement where you have to get a Current Date from Sql Server in the following format :

DD - MM - YYYY (note the hyphen in between)


So, here is the script with the Sql Server Replace function...:



Select Replace(Convert(varchar(11),Getdate(),106),' ',' - ') as 'Today'





And the Result is :





Thanks,
Nitin Sharma

Happy Coding....