January 15th, 2013, 08:26 AM
ToString Method for Saving Datetime value
how can i save date and time using ToString() Method of datetime picker in vb.
dtFrom.Value.ToString("MM/dd/yyyy") // currently i m using this but it will not give me time part. which is also mandatory for me.
required format is month day year hour min sec am/pm
my time part is always zero by using above code i can't find format strings for time part. need assistance.
January 15th, 2013, 01:07 PM
The date and time is stored as a Double Precision number relative to a particular start date (can't recall what that is at the moment). The part in front of the decimal point is the date, and the part behind is the time. It can be displayed in any different number of ways, the easiest being the system settings (long , medium, or short). The code below is VB6, but .Net will be similar.
Private Sub Command1_Click()
Dim dblDateTime As Double
dblDateTime = Now
Debug.Print Format(dblDateTime, "MM/dd/yyyy hh:mm:ss AM/PM")
01/15/13 11:06:13 AM
01/15/2013 11:06:13 AM