Hello All,
I'm working on Mysql for almost a year now but yesterday I got one issue which was killing me. I wrote a Stored Procedure in MySQL and execute it in MySQL Browser and it execute very well but when I execute the same Stored Procedure in asp.net and bind the returned DataSet with GridView, it always shows System.Byte[] in the Title Column.
The problem was that the columns which I had selected in that query was having DataType as LongText and LONGTEXT type is a kind of BLOB type (set of byte), so it was returning System.Byte[].
I checked it on google, tried different ways to fix it but nothing helped me and finally I thought firing a query on it and it worked. Something like this:
SELECT
ID
,TitleName
FROM (
SELECT
ID
,REPLACE(Title, "$", "'") AS TitleName
FROM
tbEmployee
) A
This it what I did and its working fine.
Hope this helps you all.
Happy Coding :)
Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts
Get the Monday date of a given week in a given year
A user on Silverlight forum made me to write this post.
Quoting the user question:
"I want to get first and last date of week given by a week number and year"
For example if Week Number is 26 and Year is 2009, then the output must be 29/06/2009.
However I did the first date of given week and year, here is what the logic is:
1) Get the date of the first day of the given year. That is the first date of any year would be Year + "-1-1".
2) Find out the date of the monday of this week. For example, for 2009, the first monday date would be 12-29-2008.
3) Now, when we add (number of weeks * 7) to the very first monday, we get the monday of the given week and given year.
Thats all we have to do.
Here is the sample code:
finalDate will have 6/29/2009.
Happy coding :)
Quoting the user question:
"I want to get first and last date of week given by a week number and year"
For example if Week Number is 26 and Year is 2009, then the output must be 29/06/2009.
However I did the first date of given week and year, here is what the logic is:
1) Get the date of the first day of the given year. That is the first date of any year would be Year + "-1-1".
2) Find out the date of the monday of this week. For example, for 2009, the first monday date would be 12-29-2008.
3) Now, when we add (number of weeks * 7) to the very first monday, we get the monday of the given week and given year.
Thats all we have to do.
Here is the sample code:
int iWeek = 26;
int iYear = 2009;
DateTime firstDayOfYear;
DateTime firstMondayOfYear;
DateTime finalDate;
//Step 1
firstDayOfYear = Convert.ToDateTime(iYear.ToString() + "-1-1");
DayOfWeek t = 1 - firstDayOfYear.DayOfWeek + 1;
int intDayOfWeek = (int)firstDayOfYear.DayOfWeek;
//Step 2
firstMondayOfYear = firstDayOfYear.AddDays(1 - intDayOfWeek).Date;
//Stpe 3
finalDate = firstMondayOfYear.AddDays((iWeek) * 7);
finalDate will have 6/29/2009.
Happy coding :)
Subscribe to:
Posts (Atom)