Community discussion forum

how to save only time from datetimepicker

Tags: db Netherlands
  • 7 months ago

    hi everyone...

     i have been struggling to retrive only time from datetimepicker.when i save the information both date and time is getting save but i just want time to get saved...

    plz help

    thank u

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 7 months ago

    Dim time As TimeSpan

    time = DateTimePicker1.Value.TimeOfDay

  • 7 months ago

    but this date is not getting updated in database....

    its showing the date in the form but its int getting saved...i mean both time n date r getting saved instead of date only.plz can u help me with this.......

  • 7 months ago

    What database and datatype are you using? In access you have to set the date/time format to Time, sql server 2008 has a Time datatype but the earlier versions only have a datetime which stores the whole date.

  • 7 months ago

    sql sever 2005.....and datatype is datetime.

    for this u tell me wat i should do... n wat code should i write????

  • 7 months ago

    Datetime in sql 2005 always stores a whole date (in 8 bytes) and there's nothing you can do about it. If you want to save space you can use Smalldatetime which is 4 bytes but is only accurate to the minute. If you *really* want to save space you could play around with converting the time to a number and saving as smallint or sth but that's a bad idea for many reasons...

  • 7 months ago

    the thing is im using datagrid in my project.when in displaying time its showin me date n time...thats where my problem is.... now wat do i do

  • 7 months ago

    Change the gridview cell format, for example

    dataGridView1.Columns("Time").DefaultCellStyle.Format = "t"

    will display the date in HH:mm format. For other formats see http://msdn2.microsoft.com/en-us/library/97x6twsz.aspx

     

  • 6 months ago

    I have the same problem. I used VWD 2008. I would like to display the records Time only and Date only on "GridView". The database is MS Access!

    Moreover. I need to make a search function search by date and time. So I think I cannot make the Date and time to String.

     Please help me!

Post a reply

Enter your message below

Sign in or Join us (it's free).