Community discussion forum

DateTime data type creating problem while using sqlserver with dot net 2005

  • 9 months ago
    i need to store time values in sqlserver (field type set as DateTime) but it stores data with a default date along with time entered by user at form level .how can i display only time value on the form because sqlserver doesnot provide any format settings for that field and also i am unable to find any such method in dot net that can transform that value only in time when displaying on forms....im using VB.NET
    Post was edited on 17/02/2009 06:28:16 Report abuse
  • 6 months ago

    just convert it to LongTimeString or ShortTimeString. when you store in textbox or form. example : assume you store your database value in variable.

    dim a as datetime a = ENCustomerDataTable.Rows(0).Item("EditTime") 'assume this is the value i want to store in variable

    'just show time only msgbox(a.ToLongTimeString) 'just show date only msgbox(a.ToLongDateString)

    Hope this usefull Witecloner

  • 6 months ago

    just convert it to LongTimeString or ShortTimeString. when you store in textbox or form. example : assume you store your database value in variable.

    dim a as datetime
    a = ENCustomerDataTable.Rows(0).Item("EditTime") 'assume this is the value i want to store in variable
    
    'just show time only
    msgbox(a.ToLongTimeString)
    
    'just show date only
    msgbox(a.ToLongDateString)
    

    Hope this usefull Witecloner

  • 6 months ago

    There is a TIME datatype in SQL Server 2008. But before that, you have DATETIME which allowed you to store time along with date part. If you are interested only in the time part, you just have to ignore the date part whatever it is, in your program

    www.consultsarath.info

Post a reply

Enter your message below

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

We'd love to hear what you think! Submit ideas or give us feedback