• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 898
  • Last Modified:

How to create an RFC822 pubdate using asp.net 1.1

We use a content management system which is based on asp.net framework 1.1. A developer created a page for us which generates an RSS feed from information in a database. It has worked fine, for the most part, with RSS appearing with the correct publication date in Firefox and Google Reader.

We are now trying to get the feed to appear correctly in the Windows 7 Desktop Gadget (using Feeds in IE8) - however some items don't appear at all and others appear with the wrong publication date (defaulting to Sat 30 Dec 00:00:00)

The code below is used to create the pubDate - is doesn't validate when the feed is checked, but as mentioned, most readers seem to handle it fine. What do I need to do to format the time correctly for the validator and IE?
xtwFeed.WriteElementString("pubDate", formatDateTime(dtrStatus("IncidentDateTime"),2).toString() & " " & formatDateTime(dtrStatus("IncidentDateTime"),4).toString())

Open in new window

2 Solutions
Luis PérezSoftware Architect in .NetCommented:
LSE_IT_TrainingAuthor Commented:
I can't seem to use that example to convert the text above into the correct date format. I think the problem lies with the fact I am not using Now to get the date, but dtrStatus("IncidentDateTime"). When I try and replace Now with dtrStatus("IncidentDateTime"), I get this error:

 'dtrStatus' is not a member of 'Date'.

Luis PérezSoftware Architect in .NetCommented:
Don't use Datetime.dtrStatus, but only dtrStatus.
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

LSE_IT_TrainingAuthor Commented:
I get the following error when I change:
xtwFeed.WriteElementString("pubDate", dateTime.dtrStatus("IncidentDateTime").toString("r") )
xtwFeed.WriteElementString("pubDate", dtrStatus("IncidentDateTime").toString("r") )

BC32016: 'Public Overridable Function ToString() As String' has no parameters and its return type cannot be indexed.
Jaime OlivaresSoftware ArchitectCommented:
I think the problem is that your data is not in DateTime format, so you cannot use ToString("r")
I don't know exactly how you data is formatted, but you can divide your problem in parts:

Dim d as DateTime = CType(dtrStatus("IncidentDateTime"), DateTime)

xtwFeed.WriteElementString("pubDate", d.toString("r") )

Jesse HouwingScrum Trainer | Microsoft MVP | ALM Ranger | ConsultantCommented:
You'll need to cast the object, coming from the Datarow(?), to dateTime in order to use the ToString method that accepts a format.

xtwFeed.WriteElementString("pubDate", ((DateTime)dtrStatus("IncidentDateTime")).ToString("r") )

xtwFeed.WriteElementString("pubDate", CType(dtrStatus("IncidentDateTime"), DateTime).ToString("r") )
LSE_IT_TrainingAuthor Commented:
Thanks to Jaime for the explanation of why there was a problem and to ToAoM to the exact code I needed to fix it easily.

Much appreciated.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now