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

Fabien Bodard gambas.fr at ...626...
Mon Sep 28 12:39:47 CEST 2015


Le 28 sept. 2015 09:28, "Rolf-Werner Eilert" <eilert-sprachen at ...221...>
a écrit :
>
>
> 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
>
You forgot the format function

MyDateString = format(now(),"mm/dd/yyyy")

>
>
------------------------------------------------------------------------------
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user



More information about the User mailing list