GridView BoundField Format
<asp:BoundField HeaderText="Post Date" DataField="PostDate" DataFormatString="{0:dd/MM/yyyy hh:mm:ss tt}" />
Result : 16/01/2015 01:59:46 PM
SQL Query for DateTime Range (Normally, Date has no issue)
Eg. You want to query Feb 18, 2014 to Feb 23, 2014
SELECT *
FROM [BinterWebSystem].[dbo].[tblLogHistory]
WHERE LoginTime BETWEEN '2014/02/18 00:00:00.000' AND '2014/02/23 23:59:59.999'
or (+1day to last date, if 2014/02/18, System will assume '2014/02/18 00:00:00.000')
SELECT *
FROM [BinterWebSystem].[dbo].[tblLogHistory]
WHERE LoginTime BETWEEN '2014/02/18' AND '2014/02/24'
Binding all of the Months to DropDownList
System.Globalization.DateTimeFormatInfo dtInfo = new System.Globalization.DateTimeFormatInfo();
for (int i = 1; i < 13; i++)
{
ddlStartMonth.Items.Add(new ListItem(dtInfo.GetMonthName(i), i.ToString()));
}
<asp:BoundField HeaderText="Post Date" DataField="PostDate" DataFormatString="{0:dd/MM/yyyy hh:mm:ss tt}" />
Result : 16/01/2015 01:59:46 PM
SQL Query for DateTime Range (Normally, Date has no issue)
Eg. You want to query Feb 18, 2014 to Feb 23, 2014
SELECT *
FROM [BinterWebSystem].[dbo].[tblLogHistory]
WHERE LoginTime BETWEEN '2014/02/18 00:00:00.000' AND '2014/02/23 23:59:59.999'
or (+1day to last date, if 2014/02/18, System will assume '2014/02/18 00:00:00.000')
SELECT *
FROM [BinterWebSystem].[dbo].[tblLogHistory]
WHERE LoginTime BETWEEN '2014/02/18' AND '2014/02/24'
Binding all of the Months to DropDownList
System.Globalization.DateTimeFormatInfo dtInfo = new System.Globalization.DateTimeFormatInfo();
for (int i = 1; i < 13; i++)
{
ddlStartMonth.Items.Add(new ListItem(dtInfo.GetMonthName(i), i.ToString()));
}
No comments:
Post a Comment