472,954 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,954 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 1928
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.