String to Date


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?

Nikhil Shravage.

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.
Hi Nuno,

Thanks for your quick concern. Just decoding your answer.
  1. 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
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)
  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
  Show dateattribute

Is it understandable like this?
Yes. Thank you so much for your prompt reply.

Nikhil Shravage.