From

こと++ある

There are times when I do (...)

Denotes that 'there are times/cases when (...)': it is occasionally so.

一人で夜に散歩することがあるThere are times when I go for an evening stroll by myself.

日本語を話せるが、簡単な言葉の意味を忘れることがある 。 I can speak japanese, but there are times when I forget the meaning of simple words.

少しも眠れないことがある There are times when I am not able to get even a little sleep.

Putting the ある in the past tense emphasises that there were times when you did something (but you no longer do them).

眠ることがあった I used to sleep (there have been times when I was sleeping)

聞くことがあった There have been times where I listened.

形容詞 and 形容動詞

It can also go with形容詞+ or形容動詞+ if given extra な.

飛行機の中は、臭いことがある。 The inside of an aeroplane is sometimes smelly.

公園は、静かなことがあるSometimes, the park is quiet.

With も

It can also be combined with to denote contrast

日本語の文法は、面白いこともあるThere are even times when japanese grammar is interesting (normally it is boring.)

Or just 'also'

割れていることもあるから、いつも中身をチェックする。 It also occasionally happens that it is broken, so I always check the inside.

Noun

To attach it to a noun, you need to attach an extra or a である. The meaning is identical.

ダブルブッキング==ことがある==。
ダブルブッキング==であることがある==。 Sometimes, there are double bookings.

with 〜ば

From

ことがある〜ば + ことがある

denotes that 'sometimes it happens that (...), but sometimes it happens that (...)'. This is sort of similar to the The more (...), the more (...) expression.

彼女は優しいこともあれば、怖いこともあるSometimes my girlfriend is gentle, but sometimes she is scary

本当のこともあれば、ウソのこともある。 Some things are true, some things are false.

I have done/experience in (...)

Putting the verb into the Past tense emphasises that you have experienced something before- lit. "There are times when I have done (...)" This is a very common set phrase, and for that reason many textbooks treat it as a separate grammar point.

聞いたことがある。 I have previously heard of it

こんな歌を歌ったことがない I have never sung a song like this before.

This is different from putting the ある in past tense, which emphasises that there were times when you did something (but you no longer do them).

眠ることがあった眠たことがある I used to sleep ↔ I have previously slept (there have been times when I was sleeping) ↔ (I have experienced in sleeping)

And yes, they can be used together.

眠たことがあった I once fell asleep (There have been times where I have slept)

Denoting the time until you have (not) done something is with まで

二十歳までに足を怪我したことがなかったhad never injured my leg before I was 20

最近まで海外に行ったことがなかった Up until recently, I had never gone abroad.

tofugu - たことがある tofugu - ことがある Youtube: How-to say “sometimes ...” with Dictionary-Form-VERB + ことがある