?
Solved

Dateformating

Posted on 2007-08-03
4
Medium Priority
?
204 Views
Last Modified: 2013-11-05
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>
        &nbsp; &nbsp;
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand='SELECT DISTINCT "CUSTOMER" FROM "CCI_CUSTOMER" WHERE (<%#DateString("DATE_SUBMITTED")%> = :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="SqlDataSource1"
            EmptyDataText="There are no data records to display.">
            <Columns>
                <asp:BoundField DataField="CUSTOMER" HeaderText="CUSTOMER" SortExpression="CUSTOMER" />
            </Columns>
            <EmptyDataTemplate>
                tests
            </EmptyDataTemplate>
        </asp:GridView>
        &nbsp;
    </div>
    </form>
0
Comment
Question by:Meps
3 Comments
 
LVL 7

Expert Comment

by:TheNige
ID: 19628678
If you are using SQL Server, then you can convert the DATE_SUBMITTED column in your query to just the data part by using

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.
0
 
LVL 3

Author Comment

by:Meps
ID: 19637672
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:ConnectionString %>"
            ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 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
0
 
LVL 2

Accepted Solution

by:
thaboloko earned 1500 total points
ID: 19858546
I hope this can help, change your sql string for this one:

SelectCommand="SELECT DISTINCT CUSTOMER FROM CCI_CUSTOMER WHERE Format(DATE_SUBMITTED, 'MM/dd/yyyy') = Format(@DATE_SUBMITTED, 'MM/dd/yyyy')"
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question