I wanna take the date from a .txt file like this :
933|Mahinda|Perera|male|1989-12-03|2010-03-17T13:32:10.447+0000|192.248.2.123|Firefox
1129|Carmen|Lepland|fema
As far as I can tell in my brief experiment, you don't need the gsub since gawk can compare strings by lexical order (and if your dates are YYYY-MM-DD and LANG=C, lexical and date are the same).
So I ran
gawk -F'|' -v from='1982-05-29' -v to='2010-01-01' '(from<=$5) && ($5<=to)' persons.dat.txt
and got
933|Mahinda|Perera|male|1989-12-03|2010-03-17T13:32:10.447+0000|192.248.2.123|Firefox
1129|Carmen|Lepland|female|1984-02-18|2010-02-28T04:39:58.781+0000|81.25.252.111|Internet Explorer
4194|Hồ ChÃ|Do|male|1988-10-14|2010-03-17T22:46:17.657+0000|103.10.89.118|Internet Explorer
which looks like what you want to me.
The rest of your code tries to assign to dateA and dateB, but doesn't use it anywhere. Also, it looks like you're missing a $() there: if your intention is to put the result of your date command into dateA, use dateA=$(date -d "$2" +%Y%m%d) though given that you have YYYY-MM-DD on file, dateA=$(date -d "$2" +%Y-%m-%d) look slike a better plan.