IF ELSE formula for date field

Hi,

I need help in adding a date field to Datablaze. There is a possibility that this particular field may have a date or may have -. When it does not have date, it give me following error and it does not add row in Datablaze.. How can I resolve this so that, irrespective of value of this field, it adds a row with actual date or with blank value?
image

1 Like

Does the value have - in it? Can you please share the redacted snippet?

1 Like

Can you create another variable that would conditionally change to empty if -else assign the date.

2 Likes

How to do this?
Is this correct?
{nd=({if: dtoi == "-"}{else}{time: MM/DD/YYYY; at={=dtof}; pattern=DD/MM/YYYY}{endif})}

1 Like

Something like this?

{dtoi="-"}
{if: dtoi == "-"}{nd=""}{else}{nd=dtoi}{endif}

As I do not have full context, I might not be able to recommend a better approach.

2 Likes

I actually tried below but when it is blank, datablaze command dbinsert is not working properly. It works perfectly when there are dates mentioned.

{if: doi == "-"}{doif=""}{else}{doif=({time: MM/DD/YYYY; at={=doi}; pattern=DD/MM/YYYY})}{endif}

I am trying this but not sure that IF ELSE THEN will work in dbinsert command.

{dbinsert: INSERT INTO Entities SET column=@column, CIN LLPIN=@llpin, Entity Name=@llpname, No of Partners=@nop, No of DP=@nodp, ROC Code=@roc, Registered Office=@ro, Registered Email id=@email, Contribution=@cont, Division of Business=@main, Description of Business=@description, Entity Status=@llpstatus, Date of Incorporation=@doif, {if: dtof == "-"}{else}Date of Balance Sheet=@dtoff{endif}, {if: dtoar == "-"}{else}Last Annual Return LLP=@dtoarf{endif}, Type of Entity=@type; space=; autoaddfields=no}

1 Like

Finally this worked.

image
Wherein in first two Insert Row command, I am not mapping those two fields.

Thank you for your help.

1 Like

Thanks, @Pratik_Shah
There is another workaround for now.

{dtoi="-"}
{if: dtoi == "-"}{nd=[]}{else}{nd=[({time: MM/DD/YYYY; at={=dtoi}; pattern=YYYY-MM-DD})]}{endif}
{dbinsert: INSERT INTO Table SET Name="Some name", Dt=@nd[1]; space=spaceid; autoaddfields=no}

We will try to improve this and would update you here.

3 Likes