Month name from a date

Hi,

Is it possible in navision to retreive the month name from a date.
For instance, I have the date 22/12/2005, I would like to copy 'december' in a variable.

Thanks.

Comments

  • Date
    Format
    Example

    <Closing><Day,2>-<Month,2>-<Year>
    0
    05-04-03

    <Closing><Day,2>-<Month,2>-<Year>
    1
    05-04-03

    <Day,2><Month,2><Year><Closing>D
    2
    050403D

    <Closing><Year>-<Month,2>-<Day,2>
    3
    03-04-05

    <Closing><Day>. <Month Text> <Year4>
    4
    5. April 2003

    <Closing><Day,2><Month,2><Year>
    5
    050403

    <Closing><Year><Month,2><Day,2>
    6
    030405

    <Day,2><Filler Character, >. <Month Text,3> <Year4>
    7
    5. Apr 2003





    The following table below shows how these formats will change if the Regional and Language Options is set to "United States."

    US Date
    Format
    Example

    <Closing><Month,2>/<Day,2>/<Year>
    0
    04/05/03

    <Closing><Month,2>/<Day,2>/<Year>
    1
    04/05/03

    <Month,2><Day,2><Year><Closing>D
    2
    040503D

    <Closing><Year>/<Month,2>/<Day,2>
    3
    03/04/05

    <Month Text> <Closing><Day>, <Year4>
    4
    April 5, 2003

    <Closing><Month,2><Day,2><Year>
    5
    040503

    <Closing><Year><Month,2><Day,2>
    6
    030504
  • Mark wanted to say:
      MonthName := FORMAT(Date,0,'<Month Text>');
    

    is the solution... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Thanks Kamil. :mrgreen:

    Guess I should have taken more time for this post. :oops:

    But somtimes it is more educational to puzzle your way out... O:)
  • kine wrote:
    Mark wanted to say:
    [...]

    Now we know how he gets that high number of postings:

    1. He writes a message giving just a hint
    2. He writes a message giving an extract from the on-line help
    3. He writes a message giving you the solution

    So he writes 3 messages, instead of 1 :lol:
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • Yes, and I post only posts about previous posts but only in simplier way... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Now we know how he gets that high number of postings
    =D> =D> =D> =D>
  • Thanks. It works.

    Merry Xmas. 8)
  • kine wrote:
    Mark wanted to say:
      MonthName := FORMAT(Date,0,'<Month Text>');
    

    is the solution... ;-)

    That was in the help, I should read it carefully next time... :oops:

    Thx anyway... :!: :mrgreen:
  • wolverine wrote:
    Hi,

    Is it possible in navision to retreive the month name from a date.
    For instance, I have the date 22/12/2005, I would like to copy 'december' in a variable.

    Thanks.
    Another possibility is to use the Date-virtual table
    recDate of recpord-type Date
    recDate.RESET;
    recDate.SETCURRENTKEY("Period Type","Period Start");
    recDate.SETRANGE("Period Type",recDate."Period Type"::Month);
    recDate.SETRANGE("Period Start",datMydate - 50,datMyDate);
    recDate.FIND('+');
    MESSAGE('%1',recDate."Period Name");
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • kriki wrote:

    Another possibility is to use the Date-virtual table

    Yeah, sure, and there is another possibility to write an OCX in assembly language that queries data from the observatory in Greenwich over the internet and guesses the current month from the status of the stars, and I am sure there are whole lot of other possibilities but isn't it simpler to just use FORMAT? :D:D:D

    Date table is basically for matrix forms of the usual 1/7/31/12 etc. buttons, not very handy for determining current date and such...

    Do It Yourself is they key. Standard code might work - your code surely works.
  • Could you please post an example of that OCX O:)
  • Shenpen wrote:
    Date table is basically for matrix forms of the usual 1/7/31/12 etc. buttons, not very handy for determining current date and such...
    Yes but it can also be used like this, and actually I do use it like this because after all these years with Navision, I still haven't understood the FORMAT-parameters. :oops:
    And I am not trying anymore since a few years, because I created my own functions to format numbers and dates with a format that is a lot easier to understand.

    BTW : I would also like to see an example of that OCX =P~ :)
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Hi,

    I have done this for date name by creating the codeunit.

    Name DataType Subtype Length
    DateTable Record Date
    InpDate Date


    InpDate := TODAY;

    DateTable.GET(DateTable."Period Type"::Date,InpDate);
    MESSAGE(DateTable."Period Name");

    and change like this for your requirement...

    Thanks,
    Rajasekar