date - SQL Time Format in DD/MM/YYYY hh:mm:ss -
date - SQL Time Format in DD/MM/YYYY hh:mm:ss -
how can utilize sql convert time raw format dd/mm/yyyy hh:mm:ss? current code month before date.
declare @ndays int = 1 declare @timeval int = dbo.getunixtime(dateadd(day, -@ndays,getutcdate())) declare @cstimezone varchar(256) declare @duration int select @cstimezone = timezone app_commcell id = 2 select @cstimezone = timezonestdname schedtimezone timezonename = substring(@cstimezone, charindex(':', @cstimezone, charindex(':', @cstimezone, 0) + 1) + 1, 255) ------------------------------------------------------------------------------------------ select jobid 'job id', b.servstartdate 'raw format', dbo.utctolocalstringtime(dbo.getdatetime(b.servstartdate),@cstimezone) 'mm/dd/yyyy hh:mm:ss' jmbkpstats b here result of code above.
job id raw format mm/dd/yyyy hh:mm:ss 2599 1410426012 09/11/2014 16:00:12 2611 1410432451 09/11/2014 17:47:31 2639 1410483605 09/12/2014 08:00:05 2724 1410541211 09/13/2014 00:00:11 2738 1410570009 09/13/2014 08:00:09 2750 1410598807 09/13/2014 16:00:07 2797 1410627614 09/14/2014 00:00:14 2808 1410656412 09/14/2014 08:00:12 2820 1410685211 09/14/2014 16:00:11 2847 1410714017 09/15/2014 00:00:17 2866 1410742805 09/15/2014 08:00:05 result select @cstimezone = timezone app_commcell id = 2
timezone 0:-420:(utc+07:00) bangkok, hanoi, djakarta partial result select @cstimezone = timezonestdname schedtimezone
timezonename timezonestdname (utc+07:00) bangkok, hanoi, djakarta se asia standard time
please seek code : query not tested please reply if getting error
select b.job_id, b.raw_format, convert(varchar(11),b.raw_date_column,106) raw_date_column ( select jobid 'job_id', b.servstartdate 'raw_format', dbo.utctolocalstringtime(dbo.getdatetime(b.servstartdate),@cstimezone) 'raw_date_column' jmbkpstats b ) b grouping b.job_id, b.raw_format, b.raw_date_column sql date datetime timezone format
Comments
Post a Comment