Construct Date from text

slmaluwaslmaluwa Member Posts: 364
hi
I would like to construct a date from three variables without being affected by the Regional settings in the user control panel.
nYear := 2008;
nDay  := 25;
sMon  := 'November';
dDate1 := ???

Can you please show me the way to do it?

Thank you
"A bove maiore discit arare minor"-"From the old ox, the young one learns to plow."

Answers

  • garakgarak Member Posts: 3,263
    Why the month as text and not as integer?
    nYear := 2008;
    nDay  := 25;
    sMon  := 'November';
    DateRec.reset;  //Variable of type REcord for table Date
    DateRec.SETRANGE("Period Type",DateRec."Period Type"::"Mon");
    DateRec.SETRANGE("Period Name",'November');
    DateRec.findfirst;
    dDate1 := DMY2DATE(nDay,DateRec."Period No.",nYear);
    

    Regards
    Do you make it right, it works too!
  • slmaluwaslmaluwa Member Posts: 364
    Hi Garak
    Thats the issue. We accepted this as a text (full month name) from another place. If you can help me atleast to find the number of that month in year? or other better way?
    "A bove maiore discit arare minor"-"From the old ox, the young one learns to plow."
  • garakgarak Member Posts: 3,263
    to find the no of the month you can find in the script above.
    Is the Monthname ever in the same language or is this different?
    Like: January, Januar, janvier, enero, gennaio ?
    Do you make it right, it works too!
  • slmaluwaslmaluwa Member Posts: 364
    Luckily, this text doesn't change according to the language (so far) and your solution works great.
    I didn't actually know that this month information available in Date virtual table. I almost constructed a table with all this information.
    Thank you again

    Regards
    "A bove maiore discit arare minor"-"From the old ox, the young one learns to plow."
  • garakgarak Member Posts: 3,263
    Please no problem
    Do you make it right, it works too!
Sign In or Register to comment.