RSS

Category Archives: Uncategorized

incorrect datetime value for function str_to_date


Hi,

when you use Mysql function “str_to_date” in Asp.net  code to merg code from one database to other and you can aslo move (map) Time along with Date . then common error occure after add time

SELECT STR_TO_DATE(‘[21/Apr/2009:07:14:50 +0100]’, ‘[%d/%b/%Y:%H:%i:%S +0100]’);

The SQLException does not come directly from MySQL, it’s probably triggered by your client language. MySQL will just generate a warning you can normally ignore. Whatever, the ALLOW_INVALID_DATESSQL mode should actually do the trick:

Warning:

mysql> SET @@SESSION.sql_mode='NO_ZERO_DATE,NO_ZERO_IN_DATE';
Query OK, 0 rows affected (0.00 sec)

mysql> insert into test (date_created) VALUES (str_to_date('','%m/%d/%Y'));
Query OK, 1 row affected, 1 warning (0.01 sec)

mysql> show warnings;
+---------+------+-------------------------------------------------------+
| Level   | Code | Message                                               |
+---------+------+-------------------------------------------------------+
| Warning | 1411 | Incorrect datetime value: '' for function str_to_date |
+---------+------+-------------------------------------------------------+
1 row in set (0.00 sec)

No warning:

mysql> SET @@SESSION.sql_mode='ALLOW_INVALID_DATES';
Query OK, 0 rows affected (0.00 sec)

mysql> insert into test (date_created) VALUES (str_to_date('','%m/%d/%Y'));
Query OK, 1 row affected (0.03 sec)
Specifier Description
%a Abbreviated weekday name (Sun..Sat)
%b Abbreviated month name (Jan..Dec)
%c Month, numeric (0..12)
%D Day of the month with English suffix (0th, 1st, 2nd, 3rd, …)
%d Day of the month, numeric (00..31)
%e Day of the month, numeric (0..31)
%f Microseconds (000000..999999)
%H Hour (00..23)
%h Hour (01..12)
%I Hour (01..12)
%i Minutes, numeric (00..59)
%j Day of year (001..366)
%k Hour (0..23)
%l Hour (1..12)
%M Month name (January..December)
%m Month, numeric (00..12)
%p AM or PM
%r Time, 12-hour (hh:mm:ss followed by AM or PM)
%S Seconds (00..59)
%s Seconds (00..59)
%T Time, 24-hour (hh:mm:ss)
%U Week (00..53), where Sunday is the first day of the week
%u Week (00..53), where Monday is the first day of the week
%V Week (01..53), where Sunday is the first day of the week; used with %X
%v Week (01..53), where Monday is the first day of the week; used with %x
%W Weekday name (Sunday..Saturday)
%w Day of the week (0=Sunday..6=Saturday)
%X Year for the week where Sunday is the first day of the week, numeric, four digits; used with %V
%x Year for the week, where Monday is the first day of the week, numeric, four digits; used with %v
%Y Year, numeric, four digits
%y Year, numeric (two digits)
%% A literal % character
%x x, for any x not listed above
 
Leave a comment

Posted by on November 13, 2014 in Uncategorized

 

play mp3/wav background c#


 this code u will be able to play wave as well as MP3 File if working dont forgate to mark solved

For example use this code for .mp3:

WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer();

wplayer.URL = "My MP3 file.mp3";
wplayer.Controls.Play();

For example use this code for .wav:

 

System.Media.SoundPlayer player = new System.Media.SoundPlayer();

player.SoundLocation = "Sound.wav";
player.Play();

 

 

 

 

 

 
Leave a comment

Posted by on February 11, 2014 in Uncategorized

 

Tags: , ,

How to Disable Popup Blocker?


<script type=”text/JavaScript” language=”JavaScript”>
 var mine = window.open(”,”,’width=1,height=1,left=0,top=0,scrollbars=no’);
 if(mine)
    var popUpsBlocked = false
 else
    var popUpsBlocked = true
 mine.close()
</script>

 
Leave a comment

Posted by on July 8, 2013 in Uncategorized

 

Custom Select (dropdown) change Arrow


<label>

    <select>
        <option>Sushi</option>
        <option>Blue cheese with crackers ggjgjgj jgjgjg jgjff</option>
        <option>Steak</option>
        <option>Other</option>
    </select>
</label></p>

CSS

 

 

label.custom-select {
    position: relative;
    display: inline-block;
width:100px;
}

    .custom-select select {
        display: inline-block;
        padding: 4px 3px 3px 5px;
        margin: 0;
        font: inherit;
        outline:none; /* remove focus ring from Webkit */
        line-height: 1.2;
        background: #000;
        color:white;
        border:0;
    width:100px;
    }

    /* Select arrow styling */
    .custom-select:after {
        content: “*”;
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        font-size: 60%;
        line-height: 30px;
        padding: 0 7px;
        background: #000;
        color: white;
    }
    
    .no-pointer-events .custom-select:after {
        content: none;
    }
http://www.javascriptkit.com/script/script2/dhtmlcombo.shtml

 

 

 
Leave a comment

Posted by on May 16, 2013 in Uncategorized

 

Show Long Text In The Dropdown List Of Fixed Size


<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Dropdown text show</title>
    <script>
var spacer = null;
var curObj = null;
function openIt(obj)
{
      if(spacer) return;
      spacer = document.createElement("span");
      spacer.style.width = obj.offsetWidth;
      spacer.style.height = obj.offsetHeight;
      spacer.style.display = "none";
      obj.parentNode.insertBefore(spacer, obj);
      

      obj.style.left  = getAbsPos(obj, "Left");
      obj.style.top  = getAbsPos(obj, "Top");
      obj.style.position  = "absolute";
      obj.style.width = obj.scrollWidth;
      obj.focus();
      spacer.style.display = "inline";
      curObj = obj;
     



}
function closeIt()
{
      if(spacer)
      {
            spacer.parentNode.removeChild(spacer);
            spacer = null;
      }
      if(curObj)
      {
            curObj.style.width = "100px";
            curObj.style.position  = "static";
      }
}
function getAbsPos(o,p){var i=0;while(o!=null){i+=o["offset"+p];o=o.offsetParent;}return i;}
</script>
</head>
<body>
    <table>
        <tr>
            <td bgcolor="#336600" style="width: 200px">
            <select style="width:100px" onmouseenter="openIt(this)" onchange="closeIt()" onblur="closeIt()">
                  <option>please select
                  <option>My problem is that the column is not wide enough to display the contents in the drop-down list.
                  <option>Something else
            </select>
            </td>
            <td bgcolor="#00ff33" style="width: 100px">
               </td>
            <td style="width: 100px">
            </td>
        </tr>
        <tr>
            <td style="width: 100px">
            </td>
            <td style="width: 100px">
            </td>
            <td style="width: 100px">
            </td>
        </tr>
        <tr>
            <td style="width: 100px">
            </td>
            <td style="width: 100px">
            </td>
            <td style="width: 100px">
            </td>
        </tr>
    </table>


</body>
</html>


Image
 
Leave a comment

Posted by on May 16, 2013 in Uncategorized

 

Tags: , , ,

Adding current time and date to web site


You need this within the <head></head> tags.

HTML Code:
 
 
<SCRIPT LANGUAGE="JavaScript">
function showDate()
{
	var now = new Date();
	var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
	var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
	var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
	function fourdigits(number)
	{
		return (number < 1000) ? number + 1900 : number;
	}
	
	tnow=new Date();
	thour=now.getHours();
	tmin=now.getMinutes();
	tsec=now.getSeconds();
	
	if (tmin<=9) { tmin="0"+tmin; }
	if (tsec<=9) { tsec="0"+tsec; }
	if (thour<10) { thour="0"+thour; }
	
	today = days[now.getDay()] + ", " + date + " " + months[now.getMonth()] + ", " + (fourdigits(now.getYear())) + " - " + thour + ":" + tmin +":"+ tsec;
	document.getElementById("dateDiv").innerHTML = today;
}
setInterval("showDate()", 1000);
</script>


Then this somewhere in your page.
HTML Code:
<div id="dateDiv"></div>


Image
 
Leave a comment

Posted by on April 4, 2013 in Uncategorized

 

Tags: , , ,

Change color for RadGrid Rows


hi.

If you want to  change color of RadGrid Rows.Its Simple and Past Below Code on Code Behind after Giving Datasourse

customize Color according to the specific condition or column

//RadGrid RowLoaded Event

private void grduser_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
{
if (e.Row.DataContext != null)
{
callback cbf = e.Row.DataContext as callback;
if (cbf.Status == 2)
{
//callback finished
e.Row.SetValue(BackgroundProperty, new SolidColorBrush(FromHex(“#3c94f3”)));
}
else if (cbf.Calldatetime > DateTime.Now && cbf.Calldatetime < DateTime.Now.AddMinutes(30))
{
//call back time in half hour
e.Row.SetValue(BackgroundProperty, new SolidColorBrush(FromHex(“#a4d6ff”)));
}
else if (cbf.Calldatetime < DateTime.Now)
{
//call back time passed
e.Row.SetValue(BackgroundProperty, new SolidColorBrush(FromHex(“#E98A88”)));
}
}
}

//Create  Function which Return Row color
public Color FromHex(string hex)
{
string v = hex.TrimStart(‘#’);
if (v.Length > 8) //replace with number 8
return Colors.Blue;
if (v.Length == 6)
v = “FF” + v; // Add Alpha value
if (v.Length < 6) //replace with number 6
v = “FF” + v;
while (v.Length < 8) //replace with number 8
v += “0”;
Color c = new Color();
c.A = (byte)System.Convert.ToInt32(v.Substring(0, 2), 16);
c.R = (byte)System.Convert.ToInt32(v.Substring(2, 2), 16);
c.G = (byte)System.Convert.ToInt32(v.Substring(4, 2), 16);
c.B = (byte)System.Convert.ToInt32(v.Substring(6, 2), 16);
return c;
}

 
Leave a comment

Posted by on December 19, 2011 in Silverlight, Uncategorized

 

Tags: , , , , ,