on 10-27-2014 10:02 AM
Hi,
I am loading data in kst timezone and i need to display it in cst timezone with daylight saving at target in SAP Data Service,
help me for to achieve this problem.
Thanks & Regards,
Vinodh Seemakurthi
Hi Vinodh,
In SAP Data Services 4.2 SP 03, there are two functions called local_to_utc and utc_to_local . We can use local_to_utc to convert current time zone to desired timezone . If you are using previous version means we have to write custom function.
local_to_utc(‘2014.02.01 00:00:00’, ‘UTC+08:30’) = '2014.01.31 15:30:00'
utc_to_local(‘2014.01.31 15:30:00’, ‘UTC+08:30’) = '2014.02.01 00:00:00'
Thanks & Regards,
Ramana.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vinodh,
You need to write custom function for that . There will be lot of conditions . I have written some sample script. You can follow that script and fine tune and enhance.
$DATE1 = '2014.10.28 10:00:00';
$DATE1_TIME_CHAR = to_char($DATE1,'HH24:MI:SS');
$TIMEZONE_DIFF =-15;
$YEAR = year($DATE1);
$MONTH = month($DATE1);
$DAY = day_in_month($DATE1);
$HOURS =word_ext($DATE1_TIME_CHAR,1,':');
$MINUTES =word_ext($DATE1_TIME_CHAR,2,':');
$SECONDS =word_ext($DATE1_TIME_CHAR,3,':');
$HOURS_DIFF = $HOURS +$TIMEZONE_DIFF;
if($HOURS_DIFF > 0)
begin
if($HOURS_DIFF > 24 )
begin
$HOURS = $HOURS_DIFF -24;
$DAY = $DAY +1;
end
else
begin
$HOURS = $HOURS_DIFF;
end
end
else
begin
$HOURS = 24 + $HOURS_DIFF;
$DAY = $DAY -1;
end
if($HOURS=24)
$HOURS=0;
print('Source Time :'|| $DATE1);
$DATE2_TIME_VARCHAR = $YEAR||'.'||$MONTH||'.'||$DAY||' '||$HOURS||':'||$MINUTES||':'||$SECONDS;
print('Converted Time :'|| $DATE2_TIME_VARCHAR);
I have considered only time difference between zones is hours only . We have to take care hours and minutes also . like UTC+5:30 like that.
Here again day light savings also matter. We need to add conditions for day light savings also based on months . I hope you you will some idea based on this script.
Thanks & Regards,
Ramana.
Hi venkata Ramana,
I tried another method, it is working correctly.
decode( month(sysdate( )) = '01',sysdate( )- 15/24,
month(sysdate( )) = '02',sysdate( )- 15/24,
month(sysdate( )) = '12',sysdate( )- 15/24,
sysdate( ) - 14/24 );
this is working for both normal and daylight saving,
like my if it is correct one.
Thanks & Regards,
Vinodh
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.