Skip to main content
Solved

How to Convert String Value to Date Time in Generic Inquiry


Forum|alt.badge.img

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!! 

Best answer by lauraj46

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

View original
Did this topic help you find an answer to your question?

6 replies

lauraj46
Captain II
Forum|alt.badge.img+8
  • Captain II
  • 576 replies
  • Answer
  • November 8, 2023

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


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 63 replies
  • November 8, 2023

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? 

 


lauraj46
Captain II
Forum|alt.badge.img+8
  • Captain II
  • 576 replies
  • November 8, 2023

Hi @kanupindi ,

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

Laura


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 63 replies
  • November 8, 2023

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

 

 


lauraj46
Captain II
Forum|alt.badge.img+8
  • Captain II
  • 576 replies
  • November 8, 2023

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?

 

 


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 63 replies
  • November 8, 2023

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings