Here this is generating each of the items needed for an RSS feed. In this case, because of old poor design of the database the date is stored in 3 fields, day, month and year. This code actually converts them into a correctly formatted datetime for RSS.
People forget you can do casting, string manipulation and conversions etc all in SQL. it makes for often much nicer and faster systems if you get it right.
After all, SQL as it exists in MSSQL and DB2 etc are Turing complete and fully featured programming languages.