473,395 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 1952
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Robin Lawrie | last post by:
Hi again, another problem! I've moved from an Access database to SQL server and am now having trouble inserting dates and times into seperate fields. I'm using ASP and the code below to get the...
9
by: ME | last post by:
can someone tell me how to make this first one work??, located here: http://javascript.about.com/library/scripts/blshowdatetime.htm#examplesource This second one, well, dreamweaver eats the code,...
9
by: Stefan Bauer | last post by:
Hi NG, we've got a very urgent problem... :( We are importing data with the LOAD utility. The input DATE field data is in the format DDMMYYYY (for days) and MMYYYY (for months). The target...
1
by: Miguel Dias Moura | last post by:
Hello, when i preview an ASP.net web site i am creating to a client Date and Time show as follow: Date: dd-mm-yyyy Time: hh-mm (24 hour clock. Ex: 21:45) Both Date and Time use 2 digits...
15
by: Khurram | last post by:
I have a problem while inserting time value in the datetime Field. I want to Insert only time value in this format (08:15:39) into the SQL Date time Field. I tried to many ways, I can extract...
13
by: maflatoun | last post by:
Hi, I have the following function to convert UTC time to Local time. It works perfect for GMT- (Minus) time zones however it provides incorrect results for GMT+(Plus) time zones? // Format to...
11
by: jwf | last post by:
I am writing a NON MFC C++ application (Plug-in for a 3rd party DB system). The application is designed to synchronise data between MS Outlook and the DB system. I am using smart pointers for the...
4
by: sck10 | last post by:
Hello, I created an ashx file for my rss feed (rss.ashx). I notice on the site (http://rss.msnbc.msn.com/id/3032091/device/rss/rss.xml) that the date (Yesterday, October 30, 2006, 3:02:37 PM)...
4
by: mcca0081 | last post by:
hi - i'm trying to delete one of the duplicate records based on the most current date. here's the code for my access 2000 db. any help would be appreciated!!! - thank you kindly Sub...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.