I have ODBC DSN connection that I bring into DataTable. Column Three is "TIMESTAMP".
I have...
BRANCH----| TYPE-----| TIMESTAMP
1---------------| R-----------| 14/03/2013 9:42
1---------------| R-----------| 9/01/2015 9:42
3---------------| W-----------| 13/09/2014 9:42
2---------------| R-----------| 1/03/2012 9:42
What I want is:
1---------------| R-----------| 03/2013
1---------------| R-----------| 01/2015
3---------------| W-----------| 09/2014
2---------------| R-----------| 03/2012
There seems to be some good example of this, but i cant find examples that will work on a Datacolumn.
So I use expression quite a bit in my code to truncate etc. That doesnt seem to work in this instance. I mean i have used like this previously
dcUnits.Expression = string.Format("SUBSTRING({0}, 1, 1)+''+{1}+''+{2}", "BRANCH", "TYPE", "ID");
i am not concerned if it is in the same column or a new column added.
thanks for your input :)
If I understood you well, you are having problem with the display of Timestamp column, so if you want to display it in the format MM/yyyy
try this:
//Disregard culture info if you are from US
DateTime timeStampedDateTime = DateTime.ParseExact(timeStamp, "dd/MM/yyyy H:mm", CultureInfo.GetCultureInfo("en-US"));
string mmYYYY = timeStampedDateTime.ToString("MM/yyyy", CultureInfo.GetCultureInfo("en-US"));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.