Meps
asked on
Dateformating
This is driving me nuts, simply because I am not use to working in asp.net.
Ok, my problem is I have a calendar that when you select a date it provides values from the database for customers for that day. My problem is the data in the database is datetime format. The selected value in the calendar is just date. How do I convert the data in the database into dateformat to work with the calendar? With it all in quotes, I can't use to_date().
Code.
<form id="form1" runat="server">
<div>
This is a test
<asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="Black" Font-Names="Times New Roman" Font-Size="10pt" ForeColor="Black" Height="220px" NextPrevFormat="FullMonth" Width="400px" DayNameFormat="Shortest" TitleFormat="Month">
<SelectedDayStyle BackColor="#CC3333" ForeColor="White" />
<TodayDayStyle BackColor="#CCCC99" />
<OtherMonthDayStyle ForeColor="#999999" />
<NextPrevStyle Font-Size="8pt" ForeColor="White" />
<DayHeaderStyle Font-Bold="True" Font-Size="7pt" BackColor="#CCCCCC" ForeColor="#333333" Height="10pt" />
<TitleStyle BackColor="Black" Font-Bold="True"
Font-Size="13pt" ForeColor="White" Height="14pt" />
<SelectorStyle BackColor="#CCCCCC" Font-Bold="True" Font-Names="Verdana" Font-Size="8pt"
ForeColor="#333333" Width="1%" />
<DayStyle Width="14%" />
</asp:Calendar>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Connecti onString %>"
ProviderName="<%$ ConnectionStrings:Connecti onString.P roviderNam e %>" SelectCommand='SELECT DISTINCT "CUSTOMER" FROM "CCI_CUSTOMER" WHERE (<%#DateString("DATE_SUBMI TTED")%> = :DATE_SUBMITTED)'>
<SelectParameters>
<asp:ControlParameter ControlID="Calendar1" Name="DATE_SUBMITTED" PropertyName="SelectedDate "
Type="DateTime" />
</SelectParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False " DataSourceID="SqlDataSourc e1"
EmptyDataText="There are no data records to display.">
<Columns>
<asp:BoundField DataField="CUSTOMER" HeaderText="CUSTOMER" SortExpression="CUSTOMER" />
</Columns>
<EmptyDataTemplate>
tests
</EmptyDataTemplate>
</asp:GridView>
</div>
</form>
Ok, my problem is I have a calendar that when you select a date it provides values from the database for customers for that day. My problem is the data in the database is datetime format. The selected value in the calendar is just date. How do I convert the data in the database into dateformat to work with the calendar? With it all in quotes, I can't use to_date().
Code.
<form id="form1" runat="server">
<div>
This is a test
<asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="Black" Font-Names="Times New Roman" Font-Size="10pt" ForeColor="Black" Height="220px" NextPrevFormat="FullMonth"
<SelectedDayStyle BackColor="#CC3333" ForeColor="White" />
<TodayDayStyle BackColor="#CCCC99" />
<OtherMonthDayStyle ForeColor="#999999" />
<NextPrevStyle Font-Size="8pt" ForeColor="White" />
<DayHeaderStyle Font-Bold="True" Font-Size="7pt" BackColor="#CCCCCC" ForeColor="#333333" Height="10pt" />
<TitleStyle BackColor="Black" Font-Bold="True"
Font-Size="13pt" ForeColor="White" Height="14pt" />
<SelectorStyle BackColor="#CCCCCC" Font-Bold="True" Font-Names="Verdana" Font-Size="8pt"
ForeColor="#333333" Width="1%" />
<DayStyle Width="14%" />
</asp:Calendar>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Connecti
ProviderName="<%$ ConnectionStrings:Connecti
<SelectParameters>
<asp:ControlParameter ControlID="Calendar1" Name="DATE_SUBMITTED" PropertyName="SelectedDate
Type="DateTime" />
</SelectParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False
EmptyDataText="There are no data records to display.">
<Columns>
<asp:BoundField DataField="CUSTOMER" HeaderText="CUSTOMER" SortExpression="CUSTOMER" />
</Columns>
<EmptyDataTemplate>
tests
</EmptyDataTemplate>
</asp:GridView>
</div>
</form>
ASKER
This is part of the problem, I am using Oracle.
I changed this so far, but still the same thing.
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Connecti onString %>"
ProviderName="<%$ ConnectionStrings:Connecti onString.P roviderNam e %>" SelectCommand='SELECT DISTINCT "CUSTOMER" FROM "CCI_CUSTOMER" WHERE ("DATE_SUBMITTED" = :DATE_SUBMITTED)'>
<SelectParameters>
<asp:ControlParameter ControlID="Calendar1" Name="DATE_SUBMITTED" PropertyName="SelectedDate "
Type="DateTime" />
</SelectParameters>
</asp:SqlDataSource>
In cold fusion I would just #Dateformat(date_submitted )# , but I don't know what the equivlant would be for .Net
I changed this so far, but still the same thing.
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Connecti
ProviderName="<%$ ConnectionStrings:Connecti
<SelectParameters>
<asp:ControlParameter ControlID="Calendar1" Name="DATE_SUBMITTED" PropertyName="SelectedDate
Type="DateTime" />
</SelectParameters>
</asp:SqlDataSource>
In cold fusion I would just #Dateformat(date_submitted
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Convert(DateTime, DATE_SUBMITTED,101)
101 is the style for mm//dd/yyyy without the time. If you aren't using SQL Server then you'll need to find an equivalent of this function in your DBMS.