[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

StringFormat

I want my report to filter record base on user selection of the calender date.
On page load from CodeBehind file,
i want to check if both date are select then
conver the selected date to string format:YYYY-MM-DD ieuniversalshortableDateTimePattern
and assign to string date1 and date1
the date1 and date2 will be the filter crateria for my sql command query.
0
Atouray
Asked:
Atouray
  • 4
  • 4
1 Solution
 
AtourayAuthor Commented:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Data.SqlClient;
using System.Configuration;
using eWorld.UI;
using System.Web.UI.WebControls;




namespace GambiaStat
{


    public partial class Showrejected : System.Web.UI.Page
    {

        string  date1, date2;



        protected void Page_Load(object sender, EventArgs e)
        {

            if (period1.SelectedDate && period2.SelectedDate)
            {

               // i want to  do assignments here ;
            }

 
           
        }




      



      




    }


      
        


        

        
        
        
}

Open in new window

0
 
AndyAinscowCommented:
So what is your question ?
0
 
AtourayAuthor Commented:

<td class="style5">
        <ew:CalendarPopup runat="server" id="period1"  Nullable="True" ShowGoToToday="True" 
                PopupLocation="Bottom" Culture="u"/> 
                 
        </td> 
        <td> <asp:Label ID="Label2" runat="server" Text="ENDDATE:" ForeColor="Maroon"></asp:Label>
        </td> 
        <td class="style4">
        <ew:CalendarPopup runat = "server" ID ="period2" Nullable="true" ShowGoToToday="true"
        PopupLocation ="Bottom" AutoPostBack="True" Culture="u" > </ew:CalendarPopup>
        </td>  
        %-- <div>
                  
                   <asp:GridView ID="GridView2" AutoGenerateColumns="False" runat="server" 
                          BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" 
                          CellPadding="4" DataSourceID="SqlDataSource2" Width="716px">
                       <Columns>
                           <asp:BoundField DataField="Nationality" HeaderText="Nationality" 
                               SortExpression="Nationality" />
                           <asp:BoundField DataField="Nin" HeaderText="Nin" SortExpression="Nin" />
                           <asp:BoundField DataField="gender" HeaderText="gender" 
                               SortExpression="gender" />
                           <asp:BoundField DataField="ApprovalStatus" HeaderText="ApprovalStatus" 
                               SortExpression="ApprovalStatus" />
                       </Columns>
                       <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
                       <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
                       <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
                       <RowStyle BackColor="White" ForeColor="#003399" />
                       <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
                       <SortedAscendingCellStyle BackColor="#EDF6F6" />
                       <SortedAscendingHeaderStyle BackColor="#0D4AC4" />
                       <SortedDescendingCellStyle BackColor="#D6DFDF" />
                       <SortedDescendingHeaderStyle BackColor="#002876" />
                   </asp:GridView>



                      <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                          ConnectionString="<%$ ConnectionStrings:IDKitConnectionString1 %>" 
                          SelectCommand="SELECT Nationality,Nin,gender,ApprovalStatus From Bio_data
                          where DateCreated between 'date1' and 'date2' and ApprovalStatus='Rejected'">
                      </asp:SqlDataSource>

Open in new window

0
Technology Partners: 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!

 
AtourayAuthor Commented:
how can i convert from DateTime to String in this format:
 YYYY-MM-DD ieuniversalshortableDateTimePattern
0
 
AndyAinscowCommented:
String s = dte.ToString("YYYY-MM-DD");  //Look at DateTimeFormatInfo in help for description of the options
0
 
AndyAinscowCommented:
or possibly just
String s = dte.ToString("u");
which is universal date time (which has a time unlike your example you say you require which isn't actually a universal date time)
0
 
AndyAinscowCommented:
ps - dte is a DateTime object, replace it with whatever yours are called.
0
 
AtourayAuthor Commented:
THANKS
THAT CORRECT
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now