?
Solved

How to create an RFC822 pubdate using asp.net 1.1

Posted on 2010-09-16
9
Medium Priority
?
895 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
7 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 600 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 1400 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

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

850 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