DMY2DATE for year 2010 error!!!

euekimeuekim Member Posts: 21
Hi,

i check the DMY2DATE function in Outlook Synch. Type Conversion and it gives me the wrong date

sample date is 02/12/10

Day := 12
Month := 02
Year := 10

when i used

DateVar := DMY2DATE(Day,Month,Year);

it return

2/12/0010

i assuming its 2/12/10

:(
Thinking, programming, coding, developing == Music!

Comments

  • JedrzejTJedrzejT Member Posts: 267
    Hi

    I always use parameter "year" in function DMY2DATE as 4 number year , so:
    Day := 12
    Month := 02
    Year := 10
    DateVar := DMY2DATE(Day,Month,Year);

    Just use instead
    Day := 12
    Month := 02
    Year := 2010
    DateVar := DMY2DATE(Day,Month,Year);

    Form C-Side help about Year Parameter:

    Year

    Data type: integer
    The four-digit number of the year. If you omit this optional parameter, the system uses the current year as the default.
  • xinxin Member Posts: 10
    you can try JedrzejT :)

    Anyways, did you can change the regional and language setting for your PC? change the date formats to dd/MM/yyyy and try it again?
  • JedrzejTJedrzejT Member Posts: 267
    Hi,

    I like to use function in way that i know it works fine. If 2 digit can produce some problem in some situations i prefer to not used it... not a big deal using 4 digit. When you use 2 digit? When you hardcode something - so it is wrong in other way
  • DenSterDenSter Member Posts: 8,305
    JedrzejT wrote:
    I like to use function in way that i know it works fine. If 2 digit can produce some problem in some situations i prefer to not used it... not a big deal using 4 digit.
    =D>
    Exactly. If you know 2 digits doesn't work, use 4 digits. It's not a big deal.

    It's good to know that it is an issue though, something to look for if the issue ever comes up :thumbsup:
  • matttraxmatttrax Member Posts: 2,309
    Yeah, the help says specifically to use a four digit year. If you choose not to you do so at your own risk.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    I have always used 4 digits, I can't see any reason to expect 2 digits to work, that is only for the UI entry. I once had a dataport importing from a Unix system that had 2 digit years and this was in 1998, so I created code to pseudo intelligently work out the 1900 or 2000 to add to the year to make it work.

    Has it ever been possible to use a 2 digit date? I just can't see how you can expect this if the parameter is an integer. If it was text, then there might be an assumption that it uses the same parser as the UI, but not integer. In fact if it allowed 2 digits, that would automatically exclude all years form 0 to 999 since integers automatically strip the leading zeros (obviously) so it the integers 0099 and 99 are identical.


    Sorry to be pedantic, but I just don;t see this as an error, not even a so called "undocumented feature". I see this as exactly how the function should work. :wink:
    David Singleton
  • euekimeuekim Member Posts: 21
    hi guys

    thanks for your reply, and sorry for my late response.

    :thumbsup:
    Thinking, programming, coding, developing == Music!
Sign In or Register to comment.