Skip to Content (Press Enter)
OutSystems.com
Personal Edition
Community
Support
Training
Training
Online Training
Developer Schools
Boot Camps
Certifications
Tech Talks
Documentation
Documentation
Overview
ODC
O11
Forums
Forge
Get Involved
Get Involved
Jobs
Ideas
Members
Mentorship
User Groups
Platform
Platform
ODC
O11
Search in OutSystems
Log in
Get Started
Back to Forums
Nikhil Shravage
1
Views
4
Comments
String to Date
Question
Hi!
This may seem an absurd question.
I have an entity attribute marked with Date data-type. My client needs an import feature for the project. Upon importing the data from a excel file, as per the client the data can be of non-Date format.
Any idea on how am I supposed to insert a String value as a Date type into the database?
Regards,
Nikhil Shravage.
Nuno Reis
MVP
Hi.
A string is not a date. You can either use a String attribute to store everything and convert Date when possible; or use a secondary attribute to store String when field Date is Null.
Nikhil Shravage
Hi Nuno,
Thanks for your quick concern. Just decoding your answer.
We can convert values from
String
to
Date
only if they are in valid format. Right?
For example - "12-05-2012" is inserted and then can be converted to
Date
format.
But, what if values like "IN PROGRESS" are inserted. Such values cannot be certainly converted to
Date
. In this case I should go for the second option.
Am I correct?
Thanks and regards,
Nikhil Shravage
Nuno Reis
MVP
I'll explain myself better:
1. You can use a String
attribute
and an if to show as Date or as String (data conversion functions TextToDateValidate() and TextToDate() )
if TextToDateValidate(attribute)
Show TextToDate(
attribute
)
Else
Show
attribute
Case 2.
using two separate fields, date attribute and string attribute. When the value is not a Date, save value into String attribute and a Null Date . If is a Date, save into Date attribute and a Null String.
if dateattribute=NullDate()
Show stringattribute
else
Show dateattribute
Is it understandable like this?
Nikhil Shravage
Yes. Thank you so much for your prompt reply.
Cheers!
Nikhil Shravage.
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
See the full guidelines
Loading...