You must Sign In to post a response.
  • Category: ASP.NET

    Hoe to set date from system date and time

    Hello developers,
    I want to book a room with fromdate and todate the fromdate is start from system i am done this task.Give any example for me friends

    Thanks with
  • #762119

    You can try this code for your issue

    string date= DateTime.Now.ToString();

    string date = DateTime.Now.ToString("dd/MM/yyyy);


    assign your control to date variable.

    Name : Dotnet Developer-2015
    Email Id

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #762120


    Refer the following Snapshot

    for fromdate setting current Date

    Name : Dotnet Developer-2015
    Email Id

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

    Delete Attachment

  • #762124
    Hello Paul Raj,

    For Windows Application :

    textbox1.Text = DateTime.Now.ToShortDateString();

    ASP.NET :

    this.tbDate.Text = DateTime.Today.ToString("dd/MM/yyyy");

    <asp:TextBox ID="txt_datetime" runat="server" Visible="false" Text='<%# System.DateTime.Now%>'></asp:TextBox>

    Hope this will help you.

    One more thing you have posted the question in wrong category. You have posted this thread in About DotNetSpider which is wrong for your question.

    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #762127
    Hi Paul Raj,

    First off all you need to make database as per your requirement, i.e. you need to save from and to date details irrespective of user. So, you make field like that and after table preparing we have no of date picker controls available in all technologies use any one of the datepicker for "To" date selection.

    after that you need to get dates in the below manner.

    DateTime dtfrom=DateTime.Now.ToString("dd/MM/yyyy");

    DateTime dtTo=txtDate.Text.ToString("dd/MM/yyyy");

    and store these 2 dates into database which you created earlier against user and get back based on user selection.

    Hope this will helpful to you...

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • #762603

    If you want from date to take from system by default. take label fromdate and a textbox with readonly="true"

    TextBox1.Text = DateTime.Now.ToString();

    Now current date is assigned in TextBox1, you can use it like TextBox1.Text.
    User cannot modify from date as we made that as ReadOnly="true"


    Sai Krishna Reddy.

Sign In to post your comments