We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

how to save only time from datetimepicker

Last post 05-17-2008 7:12 PM by Alexcn. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 04-28-2008 9:13 AM

    how to save only time from datetimepicker

    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

    • Post Points: 10
  • 04-28-2008 11:04 AM In reply to

    • Bart_K
    • Not Ranked
    • Joined on 02-12-2008
    • United Kingdom
    • Junior Member
    • Points 195

    Re: how to save only time from datetimepicker

    Dim time As TimeSpan

    time = DateTimePicker1.Value.TimeOfDay

    • Post Points: 10
  • 04-29-2008 6:48 AM In reply to

    Re: how to save only time from datetimepicker

    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.......

    • Post Points: 10
  • 04-29-2008 9:13 AM In reply to

    • Bart_K
    • Not Ranked
    • Joined on 02-12-2008
    • United Kingdom
    • Junior Member
    • Points 195

    Re: how to save only time from datetimepicker

    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.

    • Post Points: 10
  • 04-29-2008 9:20 AM In reply to

    Re: how to save only time from datetimepicker

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

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

    • Post Points: 10
  • 04-29-2008 9:34 AM In reply to

    • Bart_K
    • Not Ranked
    • Joined on 02-12-2008
    • United Kingdom
    • Junior Member
    • Points 195

    Re: how to save only time from datetimepicker

    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...

    • Post Points: 10
  • 04-29-2008 9:57 AM In reply to

    Re: how to save only time from datetimepicker

    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

    • Post Points: 10
  • 04-29-2008 11:18 AM In reply to

    • Bart_K
    • Not Ranked
    • Joined on 02-12-2008
    • United Kingdom
    • Junior Member
    • Points 195

    Re: how to save only time from datetimepicker

    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

     

    • Post Points: 10
  • 05-17-2008 7:12 PM In reply to

    • Alexcn
    • Not Ranked
    • Joined on 05-17-2008
    • Hong Kong SAR
    • New Member
    • Points 5

    Re: how to save only time from datetimepicker

    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 Points: 5
Page 1 of 1 (9 items)