If I buy a preferred stock before ex.dividend, will I get the dividends from the first time or there is a longer period of time should I hold the preferred shares before getting its dividends?
If you buy a preferred stock before the ex-dividend date and you own it on the ex-dividend date then you'll get the dividend. You could own the stock for as little as one day before being entitled to the dividend.
With new issues, if it pays a quarterly dividend then the first dividend may be less since the accrual period is less than 3 months.
Buying shares of stock (whether common stock or preferred stock) just before the ex-dividend date (but after the dividend has been announced) is called buying the dividend because the market price of the stock increases by the amount of the dividend (and no, this increase is not because of government regulations or stock exchange rules or any such thing, it is because the sellers demand the increased price from buyers, and buyers who have bid the lower price find no takers of their bids). After the ex-dividend date, the price falls for exactly the same reason: sellers who continue to ask for the pre-ex-dividend price find no buyers willing to pay the higher price.
If you think that investing in a particular stock is a good idea for other reasons than just the upcoming dividend, you could get more shares for a given amount of money by waiting till after the ex-dividend date to buy the shares. By buying just before the ex-dividend date, you will get fewer shares (because the price is higher) and you will get the dividend in cash (which is taxable income to you). So, you have increased your tax liability by buying the dividend whereas if you had just kept your wallet in your pocket for a few days, you could have bought more shares and avoided the tax liability. Once again, the assumption in this paragraph is that you are thinking that investing in this company is a good idea for reasons other than the upcoming dividend.