Is there anyone who knows how to retrieve the Latest date and time in the Database using Look-up Rules? without matching date and time from the field.
Hope you can help me.
Thanks.
Is there anyone who knows how to retrieve the Latest date and time in the Database using Look-up Rules? without matching date and time from the field.
Hope you can help me.
Thanks.
Not sure why you want to use SQL to do this, you can use a formula in the advanced tab to fill out the current date.
For a Single Line field, the formula would be something like:
=CONCATENATE(TEXT(RIGHT(CONCATENATE("0",TEXT(MONTH(NOW()))),2)),CHAR(47),TEXT(RIGHT(CONCATENATE("0",TEXT(DAY(NOW()))),2)),CHAR(47),TEXT(YEAR(NOW())),CHAR(9),TEXT(RIGHT(CONCATENATE("0",TEXT(HOUR(NOW()))),2)),CHAR(58),TEXT(RIGHT(CONCATENATE("0",TEXT(MINUTE(NOW()))),2)),CHAR(58),TEXT(RIGHT(CONCATENATE("0",TEXT(SECOND(NOW()))),2)))
For a Date field, the formula is much simpler and would be:
=NOW()
The latest date and time for what?
If you just need to populate a field with the current date and time, you can use the NOW() function.
I would suggest that instead of looking up using a table or view, that you execute a lookup using a stored procedure. A table based lookup is not designed to handle complex logic, but a stored procedure can perform the necessary complex processing.
Hi James Adamo I using Stored procedure to get the latest date and time also use the Look up rules to Get the date and time from stored procedure and display to Date field, but sadly it did not display into Date field what to do ?
Here's the screenshot.
Stored procedure for date
Table
Layout
Look up Rules
Hoping you can help me.
Thanks in Advance.
It is probably a format issue. I usually use DATETIME2 as the data type. I would execute the query in server management studio and check what the string representation is. Also rather than GETDATE() try SYSDATETIME(). Try something like this:
declare @jimte date = sysdatetime()
select @jimte
--or--
select convert(date, sysdatetime());
Hi Bert Warren your right! thanks for helping me for the date :)
Also I need your help regarding this...
This is the scenario, I'd like to do in Stored procedure.
Scenario: I select a value @DropDown field: WKI value and Stored the value in Stored procedure and shows the final value in a single field like this "CWPO-2021-08-WKI-001", before I submit the form I change the value of the @DropDown field to IPC because I selected a wrong value, the final value in a single field after I change the value of @DropDown field must like this "CWPO-2021-08-IPC-001", the incremental value must not be change in any selected value of @DropDown field.
2. The incremental value must reset to beginning if the month change and year change.
Hoping you can help me.
Thanks
Hi Bert Warren I have additional question regarding this...
Is it possible that I can use calculation "=MAX(table.Date)" in a date inside table to display the Latest date and time only ? sadly this syntax not working "=MAX(table.Date)" what to do?
Thanks in Advance.