Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 15th, 2013, 08:26 AM
faizy999 faizy999 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 116 faizy999 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 1 h 34 m 46 sec
Reputation Power: 10
Exclamation 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.

Reply With Quote
  #2  
Old January 15th, 2013, 01:07 PM
couttsj couttsj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 178 couttsj User rank is Sergeant Major (2000 - 5000 Reputation Level)couttsj User rank is Sergeant Major (2000 - 5000 Reputation Level)couttsj User rank is Sergeant Major (2000 - 5000 Reputation Level)couttsj User rank is Sergeant Major (2000 - 5000 Reputation Level)couttsj User rank is Sergeant Major (2000 - 5000 Reputation Level)couttsj User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 22 h 3 m 29 sec
Reputation Power: 43
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.
Code:
Private Sub Command1_Click()
    Dim dblDateTime As Double
    dblDateTime = Now
    Debug.Print dblDateTime
    Debug.Print CStr(dblDateTime)
    Debug.Print CDate(dblDateTime)
    Debug.Print Format(dblDateTime, "MM/dd/yyyy hh:mm:ss AM/PM")
End Sub

resulting in:
 41289.462650463 
41289.462650463
01/15/13 11:06:13 AM 
01/15/2013 11:06:13 AM


J.A. Coutts

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > ToString Method for Saving Datetime value

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap