Welcome Guest Search | Active Topics | Sign In | Register

DataFormat for DateTime fields Options
patingamon
Posted: Thursday, December 6, 2007 11:57:10 AM
Rank: Member
Groups: Member

Joined: 9/6/2007
Posts: 29
This code works well:

Code: HTML/ASPX
<eo:StaticColumn DataField="StartDateTime" 
    HeaderText="Day" SortOrder="Ascending" 
    DataType="DateTime" DataFormat="dddd"
    AllowSort="true"/>


And formats the code to show the full day-of-week (eg: Sunday)

However, in trying to get the time in military format this code does not work:

Code: HTML/ASPX
<eo:StaticColumn DataField="StartDateTime" 
    HeaderText="Start Time"
    DataType="DateTime" DataFormat="HH:mm"/>


Regardless of the value, it always shows the time as 00:00

and:

Code: HTML/ASPX
<eo:StaticColumn DataField="StartDateTime" 
    HeaderText="Start Time"
    DataType="DateTime" DataFormat="hh:mm"/>


Regardless of the value, it always shows the time as 12:00


Thoughts?
eo_support
Posted: Thursday, December 6, 2007 12:36:40 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
Hi,

We verified with the latest build and it appears to work fine. You will get 00:00 or 12:00 when the time part of your source data is indeed mid night --- which means it only holds an exact date value. Can you verify your data source?

Thanks
patingamon
Posted: Thursday, December 6, 2007 1:05:23 PM
Rank: Member
Groups: Member

Joined: 9/6/2007
Posts: 29
In running my test I looked at the value for the cell in question right after binding

Code: C#
+		Value	{12/27/2007 7:00:00 AM}	object {System.DateTime}


However the display in the grid still shows 12:00 or 00:00 depending on the DataFormat
eo_support
Posted: Thursday, December 6, 2007 1:22:18 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
Would you be able to create a simple test page for us to demonstrate the problem? You can create a simple object with a DateTime property, let that property to return a date time value, create an one element array containing that object, then bind the array to the Grid.
patingamon
Posted: Friday, December 7, 2007 2:32:30 PM
Rank: Member
Groups: Member

Joined: 9/6/2007
Posts: 29
Sorry, it took a long time to figure out why my test code succeeded and my real code failed. Ends up that it has to do with the DateTime object itself.

Code: C#
List<MyObject> list = new List<MyObject>();

list.Add(new MyObject(new DateTime(2007, 12, 27, 7, 0, 0))); // Failure
list.Add(new MyObject(new DateTime(2007, 12, 27, 7, 1, 0))); // Failure
list.Add(new MyObject(new DateTime(2007, 12, 27, 7, 0, 1))); // Failure
list.Add(new MyObject(new DateTime(2007, 12, 27, 0, 1, 1))); // Failure
list.Add(new MyObject(new DateTime(2007, 12, 27, 7, 1, 1))); // Success
Grid1.DataSource = list;
Grid1.DataBind();


It appears that if any of Hours, Minutes or Seconds are 0 then the DataFormat="HH:mm" returns 00:00

Thoughts?
eo_support
Posted: Friday, December 7, 2007 3:02:35 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
That is indeed the problem! We will look into it and should be able to fix it shortly.
eo_support
Posted: Friday, December 7, 2007 3:53:04 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
Hi,

We have fixed the problem and posted 2007.2.16. Please download it from our download page and see if it fixes the problem.

DataFormat for DateTimeColumn should also be in the form of "{0:xxxx}" in this version like other type of columns. So if you previous have DataFormat set to "HH:mm", you need to set it to "{0:HH:mm}" in this version, otherwise you will get a JavaScript error.

Thanks
patingamon
Posted: Sunday, December 9, 2007 1:08:49 PM
Rank: Member
Groups: Member

Joined: 9/6/2007
Posts: 29
Thanks. This version works much better.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.