Hi All,
I am getting wrong output by using Substring function in one Sql server database but correct Output in another sql server database, but not getting the reason as to why this is happening.
In the below thing, For EG : - Point 1 is giving wrong output on some sql database server while Point 2 is giving correct output on another sql server database. Can you please help on this?
1.
select Convert(nvarchar(8),Getdate(),112) + '_' + Substring(Convert(nvarchar(24),Getdate(),113),13,2) + Substring(Convert(nvarchar(24),Getdate(),113),16,2) + Substring(Convert(nvarchar(24),Getdate(),113),19,2)
Date --> 2016-10-26 21:54:03.140
Output --> 20161026_1:4:3:
2.
select getdate()
select Convert(nvarchar(8),Getdate(),112) + '_' + Substring(Convert(nvarchar(24),Getdate(),113),13,2) + Substring(Convert
(nvarchar(24),Getdate(),113),16,2) + Substring(Convert(nvarchar(24),Getdate(),113),19,2)
Date --> 2016-10-26 05:43:06.257
Output --> 20161026_054306
What I have tried:
I have tried checking this but not able to find the solution