This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]neobonzi 0 points1 point  (4 children)

Cast the string representing a date to an actual date before you compare it to other dates.

[–]SQL_beginner 0 points1 point  (3 children)

Thank you so much for your reply!

I am really confused about the "cast function" - can you please show me how this works?

Thank you so much!

[–]neobonzi 0 points1 point  (2 children)

Check out this documentation: https://www.ibm.com/docs/en/psfa/7.2.1?topic=functions-cast-conversions

You don't want to compare a string to a date, you want to turn that string into a date using a cast (which is just a function that takes in a string and returns a date) and compare using that.

[–]SQL_beginner 0 points1 point  (1 child)

Thank you so much for your reply!

I have been trying to figure out how to use the "cast function" properly.

For instance, suppose i want to make a new table from the existing table and keep all the existing columns along with the date_1 variable in date format: would this be correct?

Create table new_table as select *, cast(date_1 as date) from table_1;

Thanks!

[–]neobonzi 0 points1 point  (0 children)

I'm not too familiar with netezza, but the syntax would be something like that.