0

I'm passing a variable from my function into the date_part function but I keep getting a syntax error. Tried these 2 examples below and still got a syntax error.

Example 1:

_month = date_part('month', timestamp NEW."sdate");

Example 2:

_month = date_part('month', timestamp format('%s',NEW."sdate"));

Can anyone tell me how do I pass my variable into this function?

2
  • what is the error Commented Jan 26, 2018 at 5:15
  • syntax error at or near "format" Commented Jan 26, 2018 at 5:16

1 Answer 1

2

I think there is no need to use timestamp literal or format the string if you need to pass it to date_part function. If sdate is of type DATE , you may use it directly.

date_part('month',NEW."sdate");

If sdate is a proper date string such as '2018-01-26 13:15:20', then your first example should work fine - date_part('month', timestamp NEW."sdate");

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.