Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateTime in C++Builder5

Status
Not open for further replies.

Royt

IS-IT--Management
Jan 31, 2000
61
GB
Code Snippet:<br><br>TDateTime DateAndTime;<br>TDate&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DateOnly;<br><br>DateAndTime = Now();<br>DateOnly = DateAndTime;<br><br>Question:<br><br>Why does DateOnly take the time value as well?<br>The only way I have found to get the date part only is to take the integer part. Using cast does not work.<br><br>If you are looking for a date range the addition of the time part can make a big difference!<br><br>Can anyone suggest a neater solution?<br><br>Regards<br><br>Roy Thomas<br><br><br>
 
&nbsp;&nbsp;&nbsp;&nbsp;I'm not familiar with <i>TDate</i> but I'm assuming that it is going to accept any valid <i>TDateTime</i>. Why not use the <b>Sysutils</b> functions?<br><font color=green><br>TDateTime TheDateIs = Date();<br>TDateTime TheTimeIs = Time(); </font><br><br> <p>James P. Cottingham<br><a href=mailto: > </a><br><a href= Veneer Co., Inc.</a><br>All opinions are mine alone and do not necessarily reflect those of my employer.
 
James,<br><br>I thought I had posted a reply but perhaps I pressed the wrong button!<br><br>The choice of Now() was unfortunate. This was simple a way of getting a TDateTime value. The value is actually coming from a DateTime Picker.<br><br>My point is why have TDate (I haven't tried TTime) as well as TDateTime if TDate cannot extract the integer part.<br><br>The help file clearly states that TDate should give the date part only, so it looks like a possible bug. Is there anyone out there that can check in earlier versions of C++Builder?<br><br>Roy Thomas<br>
 
&nbsp;&nbsp;&nbsp;&nbsp;I looked up <i>TDate</i> and according to my BCB3 help files, what this returns depends on <i>Kind</i>. If <i>Kind</i> is set to <i>dtkDate</i> then it will only return a date. Did you set this?<br> <p>James P. Cottingham<br><a href=mailto: > </a><br><a href= Veneer Co., Inc.</a><br>All opinions are mine alone and do not necessarily reflect those of my employer.
 
The answer is yes.<br><br>Roy Thomas<br>
 
Further info re Dates<br><br>I have several routines using DateTimePickers which work perfectly as long as the MinDate & MaxDate properties are left blank. Once I set either or both properties to a value, i.e MaxDate to Date(), the date I enter at run time is ignored, although the bounds are applied.<br><br>Is it me?<br><br>(I have reported the problem originating this thread to Borland as a bug).<br><br>Roy Thomas<br><br><br>
 
&nbsp;&nbsp;&nbsp;&nbsp;Just our of curiosity, what version are you running?<br> <p>James P. Cottingham<br><a href=mailto: > </a><br><a href= Veneer Co., Inc.</a><br>All opinions are mine alone and do not necessarily reflect those of my employer.
 
James,<br><br>I thought I had replied on Sunday - must have pressed the wrong button again!<br><br>I am using C++Builder 5 Professional.<br><br>DateTimePicker always seems to return both the date and time regardless of whether Kind = dtkDate or Kind = dtkTime.<br><br>Since I want to pick a range of n days from the date chosen, the easy way of doing this is to start with the date in days.<br><br>Roy Thomas<br><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top