Solved

How to create an RFC822 pubdate using asp.net 1.1

Posted on 2010-09-16
9
885 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

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.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

738 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