Page 2 of 2

Re: First day of the month function?

Posted: Wed Oct 09, 2013 2:32 pm
by id10t
Hi!

[DELETED]

Re: First day of the month function?

Posted: Wed Oct 09, 2013 3:17 pm
by JimKnicely
I was going to say the same thing!

Re: First day of the month function?

Posted: Fri Mar 06, 2015 2:28 am
by Vertica4VK
Hello Jim

I have similar question - trying to figure out first day of month from a table which has a date column - I have gone through previous posts - but i get below error - i tried

dbadmin=> select to_date('my_rpt_mth_dt', 'YYYY-MM-01') from dev_data_monthly
ERROR 2005: Invalid input for YYYY: "my_rpt_mth_dt"

( i figured out another solution - but want to know if - vertica has any inbuilt formatting of date function... so i can use in above situation)

Thanks

VK

Re: First day of the month function?

Posted: Fri Mar 06, 2015 1:15 pm
by JimKnicely
Hi VK,

Instead of using the single quotes surrounding the my_rpt_mth_dt column, try the TO_CHAR function.

Code: Select all

dbadmin=> select my_rpt_mth_dt,  to_date(to_char(my_rpt_mth_dt), 'YYYY-MM-01') from dev_data_monthly;
 my_rpt_mth_dt |  to_date
---------------+------------
 2015-03-06    | 2015-03-01
(1 row)