Thanks for the code but there is a problem, the way you are formatting the date/time is incorrect. Google will show an error for times such as "1:00" as they should be zero padded like "01:00".
Rather than build each part of the date time and concat them like you are doing, just use the T-SQL Convert function using 120 as the format. Here is my version of the SQL you provided:
string mySQLCommText="select 1 as Tag,"+
" null as parent,"+
" null as [url!1],"+
" 'http://www.yoursite.com/forums/default.aspx?g=topic&f='+cast(ForumId as varchar)+ "+
" '&sd='+Name+'&ld='+Description"+
" as [url!1!loc!element],"+
" convert(varchar(20), LastPosted, 120) as [url!1!changefreq!element],"+
" 'weekly' as [url!1!changefreq!element],"+
" '0.5' as [url!1!priority!element]"+
" from yaf_Forum "+
" union all "+
" select 1 as Tag,"+
" null as parent,"+
" null as [url!1],"+
" 'http://www.yoursite.com/forums/default.aspx?g=post&t='+cast(TopicId as varchar)+ "+
" '&sd='+Topic as [url!1!loc!element],"+
" convert(varchar(20), LastPosted, 120) as [url!1!changefreq!element],"+
" 'daily' as [url!1!changefreq!element],"+
" '0.9' as [url!1!priority!element]"+
" from yaf_Topic"+
" for xml explicit";