Date/Time. Looked Everywhere. Urgent. Thanks.

S

Shapper

Hello,

I created a dataset from a XML file. One of the dataset fields is
[pubDate].

In an ASP:Repeater I am displaying the [pubDate] field.
<%# DataBinder.Eval(Container.DataItem, "pubDate", "{0:f}") %>

The date displayed has the following format, the same as in the XML
file:
Fri, 20 May 2005 12:30:00 GMT

I also tried "{0:F}", "{0:g}") as in:
http://msdn.microsoft.com/library/d...ry/en-us/vblr7/html/vafmtnameddateformats.asp

I am not able to change the date format.

Even when I change culture the date weekday and month don't change.

It seems the dataset is not recognizing the [pubDate] as date/time...


Can someone help me?

I have been trying to solve this for the past 2 days.

Thanks,
Miguel
 
S

Shapper

Hi,

You are saying to check what is the type of the [pubDate] field in my
dataset? How can I do that?

Thanks,
Miguel

Patrice said:
What if you get the type of this object ? Is this a DateTime or a String ?

Patrice

--

Hello,

I created a dataset from a XML file. One of the dataset fields is
[pubDate].

In an ASP:Repeater I am displaying the [pubDate] field.
<%# DataBinder.Eval(Container.DataItem, "pubDate", "{0:f}") %>

The date displayed has the following format, the same as in the XML
file:
Fri, 20 May 2005 12:30:00 GMT

I also tried "{0:F}", "{0:g}") as in:

http://msdn.microsoft.com/library/d...ry/en-us/vblr7/html/vafmtnameddateformats.asp


I am not able to change the date format.

Even when I change culture the date weekday and month don't change.

It seems the dataset is not recognizing the [pubDate] as date/time...


Can someone help me?

I have been trying to solve this for the past 2 days.

Thanks,
Miguel
 
P

Patrice

Instead of printing the value, print
Container.DataItem("pubDate").GetType.ToString. I should allow to find out :
- if the type is not the one expected, it would direct then to a problem in
the XML file
- if the type is the one expected, it would direct then to a formatting
issue

For now I would say 1 is more likely...

Patrice

--

Shapper said:
Hi,

You are saying to check what is the type of the [pubDate] field in my
dataset? How can I do that?

Thanks,
Miguel

Patrice said:
What if you get the type of this object ? Is this a DateTime or a String ?

Patrice

--

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> a écrit dans le message
de
Hello,

I created a dataset from a XML file. One of the dataset fields is
[pubDate].

In an ASP:Repeater I am displaying the [pubDate] field.
<%# DataBinder.Eval(Container.DataItem, "pubDate", "{0:f}") %>

The date displayed has the following format, the same as in the XML
file:
Fri, 20 May 2005 12:30:00 GMT

I also tried "{0:F}", "{0:g}") as in:

http://msdn.microsoft.com/library/d...ry/en-us/vblr7/html/vafmtnameddateformats.asp
I am not able to change the date format.

Even when I change culture the date weekday and month don't change.

It seems the dataset is not recognizing the [pubDate] as date/time...


Can someone help me?

I have been trying to solve this for the past 2 days.

Thanks,
Miguel
 
H

Hans Kesting

Shapper said:
Hello,

I created a dataset from a XML file. One of the dataset fields is
[pubDate].

In an ASP:Repeater I am displaying the [pubDate] field.
<%# DataBinder.Eval(Container.DataItem, "pubDate", "{0:f}") %>

The date displayed has the following format, the same as in the XML
file:
Fri, 20 May 2005 12:30:00 GMT

"the same as in XML" seems to mean that the XML file itself contains
the string "Fri, 20 ...". This is not the standard way to write dates into
an XML file! Standard is "yyyy-mm-ddThh:mm:ss.ffff" (not sure the "ffff"
is required)

I've never tried to go from XML to DataSet (only the other direction), but
should that converion be able to pick up number and date fields? Or would
all fields be strings? The XML file itself knows only strings!


Hans Kesting
 
S

Shapper

Hello,

Yep, I get System.String.

Is it possible, before bind the dataset to the datagrid, to change the
format of field [pubDate] from System.String to DateTime?

Then I suppose it would work?

Thanks,
Miguel

Patrice said:
Instead of printing the value, print
Container.DataItem("pubDate").GetType.ToString. I should allow to find out :
- if the type is not the one expected, it would direct then to a problem in
the XML file
- if the type is the one expected, it would direct then to a formatting
issue

For now I would say 1 is more likely...

Patrice

--

Hi,

You are saying to check what is the type of the [pubDate] field in my
dataset? How can I do that?

Thanks,
Miguel

What if you get the type of this object ? Is this a DateTime or a String
?
message
de
Hello,

I created a dataset from a XML file. One of the dataset fields is
[pubDate].

In an ASP:Repeater I am displaying the [pubDate] field.
<%# DataBinder.Eval(Container.DataItem, "pubDate", "{0:f}") %>

The date displayed has the following format, the same as in the XML
file:
Fri, 20 May 2005 12:30:00 GMT

I also tried "{0:F}", "{0:g}") as in:
http://msdn.microsoft.com/library/d...ry/en-us/vblr7/html/vafmtnameddateformats.asp
I am not able to change the date format.

Even when I change culture the date weekday and month don't change.

It seems the dataset is not recognizing the [pubDate] as date/time...


Can someone help me?

I have been trying to solve this for the past 2 days.

Thanks,
Miguel
 
S

Shapper

Hello,

This XML file is a RSS file.
Here is the RSS 2.0 Standard Format. Check the date.

http://blogs.law.harvard.edu/tech/rss

This is why I have the date in that format.

Thanks,
Miguel

Shapper said:
Hello,

I created a dataset from a XML file. One of the dataset fields is
[pubDate].

In an ASP:Repeater I am displaying the [pubDate] field.
<%# DataBinder.Eval(Container.DataItem, "pubDate", "{0:f}") %>

The date displayed has the following format, the same as in the XML
file:
Fri, 20 May 2005 12:30:00 GMT


"the same as in XML" seems to mean that the XML file itself contains
the string "Fri, 20 ...". This is not the standard way to write dates into
an XML file! Standard is "yyyy-mm-ddThh:mm:ss.ffff" (not sure the "ffff"
is required)

I've never tried to go from XML to DataSet (only the other direction), but
should that converion be able to pick up number and date fields? Or would
all fields be strings? The XML file itself knows only strings!


Hans Kesting
 
P

Patrice

Yes, how do you load data ? I would use a DateTime field not only just
before databinding but from the very beginning (if this is loaded for you,
you could likely add a datetime column, transfer the string to the datetime
column and drop the string column).

Patrice



Shapper said:
Hello,

Yep, I get System.String.

Is it possible, before bind the dataset to the datagrid, to change the
format of field [pubDate] from System.String to DateTime?

Then I suppose it would work?

Thanks,
Miguel

Patrice said:
Instead of printing the value, print
Container.DataItem("pubDate").GetType.ToString. I should allow to find out :
- if the type is not the one expected, it would direct then to a problem in
the XML file
- if the type is the one expected, it would direct then to a formatting
issue

For now I would say 1 is more likely...

Patrice

--

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> a écrit dans le message
de
Hi,

You are saying to check what is the type of the [pubDate] field in my
dataset? How can I do that?

Thanks,
Miguel
What if you get the type of this object ? Is this a DateTime or a
String

?
Patrice

--

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> a écrit dans le
message

de
Hello,

I created a dataset from a XML file. One of the dataset fields is
[pubDate].

In an ASP:Repeater I am displaying the [pubDate] field.
<%# DataBinder.Eval(Container.DataItem, "pubDate", "{0:f}") %>

The date displayed has the following format, the same as in the XML
file:
Fri, 20 May 2005 12:30:00 GMT

I also tried "{0:F}", "{0:g}") as in:

http://msdn.microsoft.com/library/d...ry/en-us/vblr7/html/vafmtnameddateformats.asp
I am not able to change the date format.

Even when I change culture the date weekday and month don't change.

It seems the dataset is not recognizing the [pubDate] as date/time...


Can someone help me?

I have been trying to solve this for the past 2 days.

Thanks,
Miguel
 
S

Shapper

Hello,

I asked you how I would change the format of the [pubDate] field in my
dataset from "String" to "DateTime" because I am having huge problems in
doing that when I load the data to the dataset.

I am loading the data from a XML file.

Here is a copy of a message I post to try to find a solution:

"I have a XML file (RSS 2.0 format). Something as follows:

<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>News</title>
<description>Latest News</description>
<item>
<title>Title</title>
<link>Url</link>
<description>Description</description>
<pubDate>Fri, 20 May 2005 12:30:00 GMT</pubDate>
</item>
...

I need to do the following:
1. Get last 10 items according to its pubDate.
2. Get the data of these items form the XML to the DataSet.
3. Make the pubDate in each DataSet row as a standard ASP.Net format.

In this moment I was able to load all items to a dataset but I wasn't
able to fulfill the objectives as I described in (1) and (3).

Here is my code:

Dim news As New XmlDocument()
news.Load("http://www.domain.com/news.rss")
Dim x As Integer
Dim xNodeList As XmlNodeList =
news.SelectNodes("/rss[@version='2.0']/channel/item")
Dim dsNews As DataSet = New DataSet()
Dim xReader As XmlTextReader
For x = 0 To xNodeList.Count-1
xReader = New XmlTextReader(xNodeList.item(x).OuterXml,
XmlNodeType.Element, new XmlParserContext(Nothing, Nothing, Nothing,
XmlSpace.None))
dsNews.ReadXml(xReader, XmlReadMode.InferSchema) Next x
"

What do you think?

Thank You,
Miguel

Patrice said:
Yes, how do you load data ? I would use a DateTime field not only just
before databinding but from the very beginning (if this is loaded for you,
you could likely add a datetime column, transfer the string to the datetime
column and drop the string column).

Patrice



Hello,

Yep, I get System.String.

Is it possible, before bind the dataset to the datagrid, to change the
format of field [pubDate] from System.String to DateTime?

Then I suppose it would work?

Thanks,
Miguel

Instead of printing the value, print
Container.DataItem("pubDate").GetType.ToString. I should allow to find

out :
- if the type is not the one expected, it would direct then to a problem
in
the XML file
- if the type is the one expected, it would direct then to a formatting
issue

For now I would say 1 is more likely...

Patrice
message
de
Hi,

You are saying to check what is the type of the [pubDate] field in my
dataset? How can I do that?

Thanks,
Miguel

"Patrice" <[email protected]> wrote in message
What if you get the type of this object ? Is this a DateTime or a
String
?


Patrice

--

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> a écrit dans le

message

de

Hello,

I created a dataset from a XML file. One of the dataset fields is
[pubDate].

In an ASP:Repeater I am displaying the [pubDate] field.
<%# DataBinder.Eval(Container.DataItem, "pubDate", "{0:f}") %>

The date displayed has the following format, the same as in the
XML
file:
Fri, 20 May 2005 12:30:00 GMT

I also tried "{0:F}", "{0:g}") as in:
http://msdn.microsoft.com/library/d...ry/en-us/vblr7/html/vafmtnameddateformats.asp
I am not able to change the date format.

Even when I change culture the date weekday and month don't
change.
It seems the dataset is not recognizing the [pubDate] as
date/time...
Can someone help me?

I have been trying to solve this for the past 2 days.

Thanks,
Miguel
 
S

Sean M

How about using DateTime.Parse() with an IFormatProvider?

For example, to parse a date specified in the US English format:

System.IFormatProvider ifProvider = new
System.Globalization.CultureInfo("en-US", false);

string strDate = "January 1, 2006";

DateTime dtDate = DateTime.Parse(strDate, ifProvider);

Shapper said:
Hello,

I asked you how I would change the format of the [pubDate] field in my
dataset from "String" to "DateTime" because I am having huge problems in
doing that when I load the data to the dataset.

I am loading the data from a XML file.

Here is a copy of a message I post to try to find a solution:

"I have a XML file (RSS 2.0 format). Something as follows:

<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>News</title>
<description>Latest News</description>
<item>
<title>Title</title>
<link>Url</link>
<description>Description</description>
<pubDate>Fri, 20 May 2005 12:30:00 GMT</pubDate>
</item>
...

I need to do the following:
1. Get last 10 items according to its pubDate.
2. Get the data of these items form the XML to the DataSet.
3. Make the pubDate in each DataSet row as a standard ASP.Net format.

In this moment I was able to load all items to a dataset but I wasn't
able to fulfill the objectives as I described in (1) and (3).

Here is my code:

Dim news As New XmlDocument()
news.Load("http://www.domain.com/news.rss")
Dim x As Integer
Dim xNodeList As XmlNodeList =
news.SelectNodes("/rss[@version='2.0']/channel/item")
Dim dsNews As DataSet = New DataSet()
Dim xReader As XmlTextReader
For x = 0 To xNodeList.Count-1
xReader = New XmlTextReader(xNodeList.item(x).OuterXml,
XmlNodeType.Element, new XmlParserContext(Nothing, Nothing, Nothing,
XmlSpace.None))
dsNews.ReadXml(xReader, XmlReadMode.InferSchema) Next x
"

What do you think?

Thank You,
Miguel

Patrice said:
Yes, how do you load data ? I would use a DateTime field not only just
before databinding but from the very beginning (if this is loaded for you,
you could likely add a datetime column, transfer the string to the datetime
column and drop the string column).

Patrice



"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> a écrit dans le message
de
Hello,

Yep, I get System.String.

Is it possible, before bind the dataset to the datagrid, to change the
format of field [pubDate] from System.String to DateTime?

Then I suppose it would work?

Thanks,
Miguel
Instead of printing the value, print
Container.DataItem("pubDate").GetType.ToString. I should allow to
find

out :
- if the type is not the one expected, it would direct then to a
problem

in
the XML file
- if the type is the one expected, it would direct then to a formatting
issue

For now I would say 1 is more likely...

Patrice

--

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> a écrit dans le
message

de
Hi,

You are saying to check what is the type of the [pubDate] field in my
dataset? How can I do that?

Thanks,
Miguel


What if you get the type of this object ? Is this a DateTime or
a

String
Patrice

--

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> a écrit dans le


de
Hello,

I created a dataset from a XML file. One of the dataset fields is
[pubDate].

In an ASP:Repeater I am displaying the [pubDate] field.
<%# DataBinder.Eval(Container.DataItem, "pubDate", "{0:f}") %>

The date displayed has the following format, the same as in
the

XML
file:
Fri, 20 May 2005 12:30:00 GMT

I also tried "{0:F}", "{0:g}") as in:

http://msdn.microsoft.com/library/d...ry/en-us/vblr7/html/vafmtnameddateformats.asp
I am not able to change the date format.

Even when I change culture the date weekday and month don't
change.


It seems the dataset is not recognizing the [pubDate] as
date/time...



Can someone help me?

I have been trying to solve this for the past 2 days.

Thanks,
Miguel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top