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

vb.net , sqlserver , visual studio 2005 Pakistan
  • 12 years 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
  • 11 years 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

  • 11 years 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

  • 11 years 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).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“C++ : Where friends have access to your private members.” - Gavin Russell Baker