Jump to content

Click the link below to see the new game I'm developing!

- - - - -

CDATE - Doesn't check strings properly

1 reply to this topic

#1 Richard Bassett

Richard Bassett

    ProIV Guru

  • Members
  • PipPipPipPipPip
  • 707 posts
  • Gender:Not Telling
  • Location:Rural France

Posted 15 November 2005 - 07:07 PM

[Tested environments: ProIV V4.6 & V5.5 on Unix]

I was trying to resolve a problem a couple of days ago and I found the CDATE logic command behaving differently than I expected. I think I've always assumed that CDATE($stringdate [, $mask]) would return zero unless $stringdate was a valid date in the format specified by mask. The code I was investigating certainly presumed that since it took a non-zero numeric returned by CDATE to mean the string date argument was valid.

However, in fact it seems CDATE is pretty lax about the validation of dates in string format, for example:

CDATE("2005-11-1", "YYYY-MM-DD") gives 75189 not 0 and, worse, that value represents the 10th November.
CDATE("2005-10-1.", "YYYY-MM-DD") gives 75172 which is the value for the 24th October (ie. totally spurious).

In fact all kinds of odd characters work in addition to digits within the month and day parts. With my C programmer hat on I'd guess ProIV is simply masking off high bits of those characters and not actually checking they are digits..

Hope this info saves someone else some time <_<

Edited by Richard Bassett, 15 November 2005 - 07:08 PM.

Nothing's as simple as you think

#2 Chris Pepper

Chris Pepper

    ProIV Guru

  • Members
  • PipPipPipPipPip
  • 369 posts
  • Gender:Male
  • Location:United Kingdom

Posted 16 November 2005 - 07:51 AM

If anyone wants to run some quick tests, the month and day components are those tested in error.

! is translated as 1, " is 2 etc. So 2005!!!" is the 12th November 2005.

Reply to this topic


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Click the link below to see the new game I'm developing!