Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai

I will get current date,time with AM or PM using this line

VB
Dim todaysdate As String = String.Format("{0:dd-MM-yyyy HH:mm tt}", DateTime.Now)

and i get this 17-03-2014 13:09 PM
So what datatype need to give for field in sql server ?
Posted

datetime[^].

See this : http://www.sql-server-helper.com/tips/date-formats.aspx[^] for getting the different versions for the date.

-KR
 
Share this answer
 
I suggest you use the DateTimePicker control which offers a convenient way for users to make a date/time selection without the hassle of date format validation. It has a property named Value in the DateTimePicker. The value directly returns a DateTime object containing the value of the DateTimePicker. You can then insert/update this value into a datetime field of a database table.
Every piece of data should be created in and stay with its native type as much as possible without unnecessary conversions.
Read about: vb.net_date_time_picker[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900