web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to use date and time in a field?

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Daniele Ferraretto Profile Picture
    on at

    I think it's possible only by code, or you could use two separate fields and after in your logic merge the information with datetimeutil class

  • Suggested answer
    Community Member Profile Picture
    on at

    Hello Anand

    To store date and time in single EDT you have to use utcdatetime EDT.

    you can refer to this link for more information

    msdn.microsoft.com/.../cc597805.aspx

  • Anand AX Profile Picture
    2,172 on at

    Hi Daniele Ferraretto,

    Now i cant create any new field for time, i have to use existing transdatetime edt only.

    Is that possible to get current time and pass it to the Transdatetime EDT field when customer select date by modified field.

  • Suggested answer
    Divya Lakshmi Profile Picture
    745 on at

    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

  • Anand AX Profile Picture
    2,172 on at

    Hello Divya,

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

  • Verified answer
    Martin Dráb Profile Picture
    237,978 Most Valuable Professional on at

    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").

  • Divya Lakshmi Profile Picture
    745 on at

    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

  • Suggested answer
    UmesH@ Profile Picture
    810 on at

    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
    745 on at

    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
    810 on at

    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans