https://slingdata.io logo
m
Hi, Something wrong in next implementation: state: from_date: > { coalesce( date_format(sync.last_sync_date, "%Y-%m-%d"), "{state.init_date}" ) } to_date: '{date_add(state.from_date, 60, "day")}' the "init_date" comes from connection in env When passing actual date instead of state, it works fine, but when Im using state.init, receiving error: fatal: ~ could not stream requests ~ could not render expression: date_add(state.from_date, 60, "day") function error: "date_add" - could not cast to time: { coalesce( date_format(sync.last_sync_date, "%Y-%m-%d"), "2023-12-01 00:00:00" The value of init_date is the same as it was when it was hardcoded
f
hey @marikt94 , you're actually inside the expression already, try removing the brackets around `"{state.init_date}"`:
Copy code
state:
      from_date: >
        {
          coalesce(
            date_format(sync.last_sync_date, "%Y-%m-%d"),
            state.init_date
          )
        }
      to_date: '{date_add(state.from_date, 60, "day")}'
m
This is was the first thing that I tried and there was also error. In the log it was like no date but "state.init_date"
I will try again tonorrow.. may be aomething with date format
f
try also
date_add(date_parse(state.from_date), 60, "day")
, since
from_date
i think is a string
m
Ok, it worked. In another situation I can see it doesnt work.. For example, in default I defined object: object: mark_sling.{stream_name}_{state.server_name} In that case it wont work, am I doing something wrong?
f
state.server_name
will not work right now, in object you only use [runtime vars](https://docs.slingdata.io/concepts/replication/runtime-variables), not the state/hook space. This will come later.