[Gambas-user] CDATE
Tobias Boege
taboege at ...626...
Wed Dec 3 17:36:21 CET 2014
On Wed, 03 Dec 2014, Lewis Balentine wrote:
> Ref: http://gambaswiki.org/wiki/lang/cdate
>
> Date = CDate ( Expression AS Variant ) AS Date
> Converts an expression (numerical Float or String) into a Date / Time.
> Be careful! The current localization is not used by this function.
>
> Is there a reference for what string formats CDATE recognizes.
> The input date I have is in form "ccyymmdd".
> Changing it to to "ccyy/mm/dd"did not work.
> Reversing it to "dd/mm/ccyy"did not work.
>
> Error is type mismatch: wanted date, got string instead.
> Date is "20141215" (aka 15 Dec 2014).
>
I couldn't find a place where that's documented but you can safely assume
that the non-localised conversion functions (i.e. the "C<Type>()" ones) are
compatible. If you want to know the format of a string to put into CDate(),
try to put a date into CStr() and see what it gives you:
$ gbx3 -e "CStr(Now)"
12/03/2014 17:27:48.308
and I bet the date or time part is optional and the milliseconds part alone
is also optional (didn't test).
You can implement a simple parser for your custom date formats using Scan()
and the Date() function... I'll leave that to you ;-)
Regards,
Tobi
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
More information about the User
mailing list