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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateFormat Property

Status
Not open for further replies.

SGLong

Programmer
Jun 6, 2000
405
US
I originally posted this in the VFP General forum, and my e-mail indicates that there were 3 replies. The site-manager, in his infinite wisdom, deleted the thread before I could read it and sent me the following e-mail: "Please make that last post in the Microsoft: VFP - Forms, Classes and Controls forum -- you'll get the best replies". Would whoever responded please re-respond.


I have a text box control that references a DateTime field in a SQL table. All I care about is the date portion, but the field always tries to show the full date/time value.

I've tried setting the DateFormat property to 1 (American), 10 (MDY), and 14 (Long) but the field still shows (and permits) time entry. I'm unable to put any characters in the InputMask property - no matter what I type (##/##/#### or 99/99/9999) when I hit Enter it shows NONE as the property.

How can I format this text box so it doesn't have any time component?

Steve
 

Would whoever responded please re-respond.
There were two of us. Here is the summary.

You don't really need InputMask property.

Just set your initial Value property to {} (or a valid date), and you will be able to enter dates in the format of your current SET DATE/SET CENTURY settings. This is valid for all Date type, and may be working for DateTime, too.

If the time part still showing, you might also need to use some intermediate variable as your ControlSource property converted into Date type by using TTOD(); then convert it back to DateTime using DTOT() or DateTime().

But there was a suggestion that {} alone might do the trick of conversion, and then SQL will automatically convert into DateTime.
 
Thanks, Stella...

I'll let you know if that solves the problem.

Steve
 
I've been working on another project of higher priority the past week... I'm hoping to get back to this later on this week... I'll let you know my results.
 
Stella,

I did have the initial value property defined as {}, but the field still displayed as a DateTime value. What I finally ended up doing was putting the following code (in part) in the refresh event of the container.

Code:
LOCAL dTemp
dTemp = EVALUATE(this.cnt_source)
IF VARTYPE(dTemp) = 'T'
   dTemp = TTOD(dTemp)
ENDIF 
this.date_field.value = dTemp

Thanks for the suggestions.

Steve


 

Steve,

I've seen this same question asked here several times over the years.

Maybe you should write your solution as a FAQ for the benefit of others who have the same problem.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 

Mike,

Do using {/} for a date and {/:} for a datetime help?

This wouldn't help to get rid of the time part of DateTime type in the text box, would it?
Then what can it help with?
 
Mike,

Actually this text box is part of a date entry class that I made. It has a spinner, an optional command button for a popup calendar, and 3 formats of date display (day, date, day & date) which are in different colors for weekends and holidays.

When it was used in our VFP application where our fields were strictly date fields it wasn't a issue. When we migrated to SQL-Server where the only choice is date-time is when it became a problem.

I might take you up on the idea of submitting a FAQ on this.

Steve

Steve

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top