Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

How to use date and time in a field?

Posted on by 2,172

Hello All,

I want date and time in a single field. For which i used TransDateTime EDT. but when i select, only date value is coming, time is always Zero.

1. How to get date and time? Is there any other EDT..? Or possible only by coding?

2. Also Customer select any date(not only current date), but it should bring current time, Is that possible?

please Clarify me!

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to use date and time in a field?

    Thank you, 

    finally,

    DateTimeUtil::utcNow()


  • Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    RE: How to use date and time in a field?

    Could you please mark the verified answers? This thread is still not displayed as resolved...

  • Divya Lakshmi Profile Picture
    Divya Lakshmi 745 on at
    RE: How to use date and time in a field?

    Dear team ,

    Sorry for my last reply ..it was my misunderstanding..Thank u for explanations..I'm clear now..and got some info....

    Thanks & Regards,

    Divya lakshmi.J

  • Suggested answer
    UmesH@ Profile Picture
    UmesH@ 810 on at
    RE: How to use date and time in a field?

    you can use built in funtion as below:

    1)date
    static void date2StrExample(Args _arg)
    {
        date d = today();
        str s;
        ;
        s = date2Str(d, 123, 2, -1, 2, -1, 2);
        print "Today's date is " + s;
        pause;
    }
    2) time
    static void timeNowExample(Args _arg)
    {
        int i;
        ;
        i = timeNow();
        print "The number of seconds since midnight is " + int2Str(i);
        pause;
    }

    3) use Time to str function to convert time in second form your desire format.
    // Returns the text string 05:01:38.
    time2Str(18098,1,1);
    // Returns the text string 05:01:38 am.
    time2Str(18098,1,2);
    // Returns the text string 05 01 39.
    time2Str(18099,3,1);
    // Returns the text string 05/01/39 am.
    time2Str(18099,5,2);
     
    4) finally using 1,2 & 3 you can get date&time.
    no

  • Divya Lakshmi Profile Picture
    Divya Lakshmi 745 on at
    RE: How to use date and time in a field?

    3175.Test-UTCTIME.PNGHi Jignesh ,

    I have replicated what you have replied. But its reflecting the same issue.

    Please find screenshot. I Want to know any other settings to be checked in preferred time zone.

    Regards,

    Divya Lakshmi.J

  • Suggested answer
    UmesH@ Profile Picture
    UmesH@ 810 on at
    RE: How to use date and time in a field?

    insert in table Date,Time and Datetime

    • if Date inserted then Check EDT (extendedDataType) Property is basedate.
    • if Time inserted then Check EDT (extendedDataType) Property is Timeofday.
    • if DateTime inserted then Check EDT (extendedDataType) Property is UTCTimestamp.

    DateTime.JPG

    if you have to Seperate Date then Use

    Here DateP is BaseDate;

    date2str(dateP,123,DateDay::Digits2,DateSeparator::Hyphen,DateMonth::Digits2,
    DateSeparator::Hyphen,DateYear::Digits4);

    Or Else You Can Dynamically Inserted Date and Time in Your table.

    Thanks.

  • Divya Lakshmi Profile Picture
    Divya Lakshmi 745 on at
    RE: How to use date and time in a field?

    Test-UTCTIME.PNGHi,

      Anand is right.He mean to say that if a new field created of type UTCDATETIME and if I create a record(ie.If I select todays date by 10.50AM )the record shows only the date but with the time 12.00AM...and not as 10.50 AM

    please find attachment for the demo of his scenario.

    @Anand :correct me if i'm wrong

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    RE: How to use date and time in a field?

    This is how you can assign the current time:

    yourTable.YourField = DateTimeUtil::utcNow();

    Note that I don't understand the latter part of your requirement ("to get current time and pass it to the Transdatetime EDT field when customer select date by modified field").

  • Anand AX Profile Picture
    Anand AX 2,172 on at
    RE: How to use date and time in a field?

    Hello Divya,

    I used already as you said, but whatever date i select(including current date), the date only coming, time is not..!

  • Suggested answer
    Divya Lakshmi Profile Picture
    Divya Lakshmi 745 on at
    RE: How to use date and time in a field?

    Hi,

    Right click on fields node and create a field of type UTCDateTime.This will store date and time simultaneously. If u select today date, then the field will store the today date and current time.

    Regards,

    Divya Lakshmi.J

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans