Solved

How to create an RFC822 pubdate using asp.net 1.1

Posted on 2010-09-16
9
880 Views
Last Modified: 2013-11-18
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

0
Comment
Question by:LSE_IT_Training
9 Comments
 
LVL 25

Expert Comment

by:Luis Pérez
ID: 33691119
0
 

Author Comment

by:LSE_IT_Training
ID: 33692958
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'.


0
 
LVL 25

Expert Comment

by:Luis Pérez
ID: 33694460
Don't use Datetime.dtrStatus, but only dtrStatus.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:LSE_IT_Training
ID: 33777233
I get the following error when I change:
xtwFeed.WriteElementString("pubDate", dateTime.dtrStatus("IncidentDateTime").toString("r") )
to:
xtwFeed.WriteElementString("pubDate", dtrStatus("IncidentDateTime").toString("r") )

BC32016: 'Public Overridable Function ToString() As String' has no parameters and its return type cannot be indexed.
0
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 150 total points
ID: 33904046
LSE,
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") )

0
 
LVL 17

Accepted Solution

by:
Jesse Houwing earned 350 total points
ID: 33906113
You'll need to cast the object, coming from the Datarow(?), to dateTime in order to use the ToString method that accepts a format.

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

VB.NET:
xtwFeed.WriteElementString("pubDate", CType(dtrStatus("IncidentDateTime"), DateTime).ToString("r") )
0
 

Author Closing Comment

by:LSE_IT_Training
ID: 33927516
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now