on ā2025 Jan 22 12:07 PM
Hi SAP Community,
I am encountering an issue while working on a calculated column (CD_SNAPSHOT_DATE) in Data Flows in SAP Datasphere.
We have calculated columns in a Fact View to derive the current date using the following expression:
TO_DATS(UTCTOLOCAL(CURRENT_TIMESTAMP, 'US/Central')).
I need to create a Calculated Column similar to this in Data Flow For Snapshot Date if I use the above expression I am getting the below error:
UTCTOLOCAL function only supports UTC offset timezone formats.
To address this, I updated the expression to use a UTC offset format as follows:
1.TO_DATS(UTCTOLOCAL(CURRENT_TIMESTAMP, '-06:00'))
2.TO_DATS(UTCTOLOCAL(CURRENT_TIMESTAMP, 'UTC-6'))
However, this also throws the same error.
Thank you in advance for your guidance and suggestions!
Best regards,
Ganga Reddy Somu
Request clarification before answering.
It worked for me with TO_DATE(UTCTOLOCAL(CURRENT_UTCTIMESTAMP(),'UTC+5.30'))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can try using the below option:
TO_DATE(UTCTOLOCAL (CURRENT_UTCTIMESTAMP, 'EST') )
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can create a new calculated column of data type 'Date' and use the expression CURRENT_UTCDATE().
Regards
Githen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You will be able to calculate dynamically using Python script operator. You may have to adjust below script based on your dataframe structure.
# Helper function to calculate the second Sunday of March
def get_second_sunday(year):
# March 1st
first_day = pd.Timestamp(year=year, month=3, day=1)
# Find the first Sunday (add the days until Sunday)
first_sunday = first_day + pd.Timedelta(days=(6 - first_day.weekday()) % 7)
# The second Sunday is 7 days after the first Sunday
second_sunday = first_sunday + pd.Timedelta(days=7)
return second_sunday
# Helper function to calculate the first Sunday of November
def get_first_sunday(year):
# November 1st
first_day = pd.Timestamp(year=year, month=11, day=1)
# Find the first Sunday (add the days until Sunday)
first_sunday = first_day + pd.Timedelta(days=(6 - first_day.weekday()) % 7)
return first_sunday
# Function to adjust the timestamp based on DST for US Central Time
def adjust_for_dst(current_date):
year = current_date.year
# Get DST start and end dates
dst_start = get_second_sunday(year)
dst_end = get_first_sunday(year + 1) # DST ends in the next year
# Check if current date is within the DST range
if dst_start <= current_date < dst_end:
# Apply UTC-5 for CDT
adjusted_time = current_date - pd.Timedelta(hours=5)
else:
# Apply UTC-6 for CST
adjusted_time = current_date - pd.Timedelta(hours=6)
return adjusted_time
# Example usage:
current_date = pd.Timestamp.now(tz='UTC') # Current UTC time
data[adjusted_date] = adjust_for_dst(current_date)
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 6 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.