![]() |
|
|
|||||||
![]() |
ASP Net - How do I convert a DateTime table column to a TimeSpan or DayOfWeek ? |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
The context is shown below in the getGames() method.
I get errors on these lines: dtGames.Rows[i]["playTime"] = (TimeSpan)dtGames.Rows[i]["playDate"]; dtGames.Rows[i]["playDay"] = (DayOfWeek)dtGames.Rows[i]["playDate"]; because the playDate column is a DateTime. Here is my solution but I don't like it. What else can I do? dtGames.Rows[i]["playTime"] = Convert.ToDateTime(dtGames.Rows[i]["playDate"]).TimeOfDay; dtGames.Rows[i]["playDay"] = Convert.ToDateTime(dtGames.Rows[i]["playDate"]).DayOfWeek; public DataView getGames() { DataTable dtGames = DAL.GetTable("Games"); DataColumn colItem; colItem = new DataColumn("playTime", Type.GetType("System.TimeSpan")); dtGames.Columns.Add(colItem); colItem = new DataColumn("playDay", Type.GetType("System.DayOfWeek")); dtGames.Columns.Add(colItem); for (int i = 0; i <= dtGames.Rows.Count - 1; i++) { dtGames.Rows[i]["playTime"] = (TimeSpan)dtGames.Rows[i]["playDate"]; dtGames.Rows[i]["playDay"] = (DayOfWeek)dtGames.Rows[i]["playDate"]; } dvwGames = dtGames.DefaultView; Cache.Insert("Games", dvwGames); return dvwGames; } Harry Haller |
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to Rip DVD and Convert Video on Mac OS | dave345 | Media | 12 | 07-07-2008 09:32 AM |
| MCITP and stored procedure permissions | Darrilgibson@gmail.com | MCITP | 5 | 06-07-2008 12:37 PM |
| Guide-how to choose the most satisfactory software to convert DVD to your mobile devices | bobo | DVD Video | 0 | 08-07-2006 03:01 AM |
| How to convert DVD/Video to iPod/PSP? | ivan | DVD Video | 0 | 04-12-2006 09:25 AM |