Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Date and Time Variables different from one another in ty
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00253129
Message ID:
00253141
Views:
19
>>>>As part of output which is redirected to a file, I have run into the following situation. The code
>>>>
>>>>? "message" + time()
>>>>
>>>>works fine and prints to the screen
>>>>
>>>>but the code
>>>>
>>>>? "message" + date()
>>>>
>>>>causes a type mismatch
>>>>
>>>>anyone know why?
>>>
>>>Hi Thomas,
>>>
>>>DATE() returns a date datatype and you're trying to display it as a string when you ? "message " + date(). You can use:
>>>
>>>? "message " + DTOC(DATE())
>>>
>>>or
>>>
>>>? " message " + TTOC(DATE()) && or DATETIME() as the parameter.
>>
>>Or you can use the trick you turned me on to yesterday:
>>
>>? "message "+TRANSFORM(DATE()) && (VFP6 only, of course)
>
>Yep that'll work too, Fred. So will:
>
>? "message", DATE()
>
>The problem's caused by VFP attempted to concatenate the date data type into a single string (which, of course, I'm sure you know). Frankly, I didn't think of the above until after I had posted my response< g >.

Almost always more than one to do it in FoxPro. I had almost forgotten about the comma list for a ? command.

You can also do:
? "message "+TRANSFORM(DATE(),"") && works in ALL versions of FoxPro
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Previous
Reply
Map
View

Click here to load this message in the networking platform