Hi yogeshc,
I have created sample. Refer the below sample.
SQL
CREATE TABLE SaveDateTimeFormat
(
ID INT IDENTITY,
ddmmyyyy DATETIME,
dmyyyy DATETIME,
ddmyyyy DATETIME,
dmmyyyy DATETIME
)
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<style type="text/css">
body
{
line-height: 0;
}
.dropdown-menu
{
font-size: 10px;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.1/css/bootstrap-datepicker.css" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.1/js/bootstrap-datepicker.min.js"></script>
<script type="text/javascript">
$(function () {
$('#txtDateTimeddmmyyyy').datepicker({ format: 'dd/mm/yyyy', autoclose: true });
$('#txtDateTimedmyyyy').datepicker({ format: 'd/m/yyyy', autoclose: true });
$('#txtDateTimeddmyyyy').datepicker({ format: 'dd/m/yyyy', autoclose: true });
$('#txtDateTimedmmyyyy').datepicker({ format: 'd/mm/yyyy', autoclose: true });
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div style="padding-left: 15px;">
<div class="input-group date datepicker col-md-12 col-xs-12" >
<input id="txtDateTimeddmmyyyy" class="form-control" type="text" runat="server" placeholder="dd/mm/yyyy" />
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
</span>
<input id="txtDateTimedmyyyy" class="form-control" type="text" runat="server" placeholder="d/m/yyyy" />
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
<div class="input-group date datepicker col-md-12 col-xs-12" >
<input id="txtDateTimeddmyyyy" class="form-control" type="text" runat="server" placeholder="dd/m/yyyy" />
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
</span>
<input id="txtDateTimedmmyyyy" class="form-control" type="text" runat="server" placeholder="d/mm/yyyy" />
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
<asp:Button Text="Save" ID="btnSave" runat="server" CssClass="btn btn-default" OnClick="Save" />
</div>
</form>
</body>
</html>
C#
protected void Save(object sender, EventArgs e)
{
DateTime dateTimeddmmyyyy = DateTime.ParseExact(txtDateTimeddmmyyyy.Value, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
DateTime dateTimedmyyyy = DateTime.ParseExact(txtDateTimedmyyyy.Value, "d/M/yyyy", System.Globalization.CultureInfo.InvariantCulture);
DateTime dateTimeddmyyyy = DateTime.ParseExact(txtDateTimeddmyyyy.Value, "dd/M/yyyy", System.Globalization.CultureInfo.InvariantCulture);
DateTime dateTimedmmyyyy = DateTime.ParseExact(txtDateTimedmmyyyy.Value, "d/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings[1].ConnectionString))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.Connection = con;
cmd.CommandText = "INSERT INTO SaveDateTimeFormat VALUES('" + dateTimeddmmyyyy + "','" + dateTimedmyyyy + "','" + dateTimeddmyyyy + "','" + dateTimedmmyyyy + "')";
cmd.CommandType = System.Data.CommandType.Text;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
VB.Net
Protected Sub Save(sender As Object, e As EventArgs)
Dim dateTimeddmmyyyy As DateTime = DateTime.ParseExact(txtDateTimeddmmyyyy.Value, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture)
Dim dateTimedmyyyy As DateTime = DateTime.ParseExact(txtDateTimedmyyyy.Value, "d/M/yyyy", System.Globalization.CultureInfo.InvariantCulture)
Dim dateTimeddmyyyy As DateTime = DateTime.ParseExact(txtDateTimeddmyyyy.Value, "dd/M/yyyy", System.Globalization.CultureInfo.InvariantCulture)
Dim dateTimedmmyyyy As DateTime = DateTime.ParseExact(txtDateTimedmmyyyy.Value, "d/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture)
Using con As New SqlConnection(ConfigurationManager.ConnectionStrings(1).ConnectionString)
Using cmd As New SqlCommand()
cmd.Connection = con
cmd.CommandText = "INSERT INTO SaveDateTimeFormat VALUES('" + dateTimeddmmyyyy + "','" + dateTimedmyyyy + "','" + dateTimeddmyyyy + "','" + dateTimedmmyyyy + "')"
cmd.CommandType = System.Data.CommandType.Text
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Using
End Using
End Sub
Screenshot