[Gambas-user] Return Value of Date() function

Rolf-Werner Eilert eilert-sprachen at ...221...
Mon Sep 28 09:27:17 CEST 2015


Am 25.09.2015 14:44, schrieb Tobias Boege:
> On Fri, 25 Sep 2015, emanuele sottocorno wrote:
>> As stated in the wiki the Date Function should return a date without its
>> time component.
>> http://gambaswiki.org/wiki/cat/time
>>
>> But: Print Date(Now) ---> 25/09/2015 00:00:00
>>
>> Is it by design?
>>
> The Date() function returns data of type Date. This datatype is designed to
> hold date and time information, so there is no way to return a date in a
> Date value without a time component.
>
> You should think of the Date() function as *stripping* the time information
> from a Date value, by replacing the time information with zeros.
>
> Regards,
> Tobi
>
So the correct way to handle this if I wish to process the date would be 
either to use the built-in functions day(), month(), year() and then 
connecting them to whatever, or make a string out of it to be used. Right?

myDateString = String.Left(CStr(Date(Now)),  10)

The same way if you do need the time information (e. g. for making a 
file name by date+time), but then it's easier to use Mid or String.Mid 
to peek the values and concatenate them to form a file name the way you 
need it.

Rolf





More information about the User mailing list