Solved

How to Convert String Value to Date Time in Generic Inquiry

  • 8 November 2023
  • 6 replies
  • 110 views

Userlevel 4
Badge

We would like to display an attribute stored as text to date time. Below is the attribute

Attribute

We would like to create something similar for End Time and calculate the difference between the two fields. 

 

Start Time End Time Difference
2:30 pm 5:30 pm 3 hours or 180 mins

 

 

We tried using CDate() function and it errors out (=cdate([INKitRegister.AttributeSTARTTIME]))

How can I fix this issue? 

 

@lauraj46 -Hi Laura, do you have any ideas, thank you as always!

 

Any help would be appreciated!! 

icon

Best answer by lauraj46 8 November 2023, 04:12

View original

6 replies

Userlevel 7
Badge +7

Hi @kanupindi ,

Try this formula to convert the STARTDATE text string to a date:

=CDate('1/1/1900 ' + left([INKitRegister.AttributeSTARTTIME], 2) + ':' + substring([INKitRegister.AttributeSTARTTIME], 3, 2) + ' ' + right([INKitRegister.AttributeSTARTTIME], 2))

And this to find the difference between STARTDATE and ENDDATE in minutes:

=datediff('n', CDate('1/1/1900 ' + left([INKitRegister.AttributeSTARTTIME], 2) + ':' + substring([INKitRegister.AttributeSTARTTIME], 3, 2) + ' ' + right([INKitRegister.AttributeSTARTTIME], 2)), CDate('1/1/1900 ' + left([INKitRegister.AttributeENDTIME], 2) + ':' + substring([INKitRegister.AttributeENDTIME], 3, 2) + ' ' + right([INKitRegister.AttributeENDTIME], 2)))

Note that text fields are stored internally without the colon and the space that are specified in the input mask.

Hope this helps!

Laura

Userlevel 4
Badge

Hi @lauraj46, thank you so much for taking the time to replicate the issue. Is there a way to only display the time and not the date? Something like the one below? 

 

Userlevel 7
Badge +7

Hi @kanupindi ,

For that you could just display the attribute field, without any formulas.

Laura

Userlevel 4
Badge

Hi @lauraj46, if we display the attribute field without any formulas - it does not work because it displays the values as text and not in hours and minutes. We would like it to show the time without the date

 

 

Userlevel 7
Badge +7

Hi @kanupindi ,

If you choose the attribute field from the dropdown then it will be displayed using the mask.  Is that what you’re looking to accomplish?

 

 

Userlevel 4
Badge

Hi @lauraj46, I completely missed that, thank you so much for always helping quickly! You are a genius! 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved