468,101 Members | 1,449 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,101 developers. It's quick & easy.

Date/Time. Looked Everywhere. Urgent. Thanks.

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/de...ateformats.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

Nov 19 '05 #1
9 1726
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 news:uK****************@TK2MSFTNGP10.phx.gbl...
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/de...ateformats.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

Nov 19 '05 #2
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" <no****@nowhere.com> wrote in message news:no****@nowhere.com:
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 news:uK****************@TK2MSFTNGP10.phx.gbl...
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/de...ateformats.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


Nov 19 '05 #3
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 news:OI**************@TK2MSFTNGP10.phx.gbl...
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" <no****@nowhere.com> wrote in message news:no****@nowhere.com:
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 news:uK****************@TK2MSFTNGP10.phx.gbl...
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/de...ateformats.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

Nov 19 '05 #4
Shapper wrote:
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

Nov 19 '05 #5
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" <no****@nowhere.com> wrote in message news:no****@nowhere.com:
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 news:OI**************@TK2MSFTNGP10.phx.gbl...
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" <no****@nowhere.com> wrote in message news:no****@nowhere.com:

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 news:uK****************@TK2MSFTNGP10.phx.gbl...
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/de...ateformats.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
>



Nov 19 '05 #6
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

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:ne***********@spamgourmet.com:
Shapper wrote:
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


Nov 19 '05 #7
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 news:%2****************@TK2MSFTNGP10.phx.gbl...
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" <no****@nowhere.com> wrote in message news:no****@nowhere.com:
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 news:OI**************@TK2MSFTNGP10.phx.gbl...
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" <no****@nowhere.com> wrote in message news:no****@nowhere.com:

> 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 news:uK****************@TK2MSFTNGP10.phx.gbl...
>

> > 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/de...ateformats.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
> >


Nov 19 '05 #8
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" <no****@nowhere.com> wrote in message news:no****@nowhere.com:
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 news:%2****************@TK2MSFTNGP10.phx.gbl...
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" <no****@nowhere.com> wrote in message news:no****@nowhere.com:

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 news:OI**************@TK2MSFTNGP10.phx.gbl...
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" <no****@nowhere.com> wrote in message
news:no****@nowhere.com:

> 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 news:uK****************@TK2MSFTNGP10.phx.gbl...
> >
> > 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/de...ateformats.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
> > >

>



Nov 19 '05 #9
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" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:eL**************@TK2MSFTNGP14.phx.gbl...
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" <no****@nowhere.com> wrote in message news:no****@nowhere.com:
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 news:%2****************@TK2MSFTNGP10.phx.gbl...
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" <no****@nowhere.com> wrote in message news:no****@nowhere.com:

> 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 news:OI**************@TK2MSFTNGP10.phx.gbl...
>

> > 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" <no****@nowhere.com> wrote in message


news:no****@nowhere.com:
> >
>

> > > 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 news:uK****************@TK2MSFTNGP10.phx.gbl...
> > >
>

> > > > 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/de...ateformats.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
> > > >
>
> >


Nov 19 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by ME | last post: by
9 posts views Thread by Stefan Bauer | last post: by
13 posts views Thread by maflatoun | last post: by
11 posts views Thread by jwf | last post: by
4 posts views Thread by sck10 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.