Use dates within an equation field
Forums
Hi Bryant,
I wanted to asked about a problem I 'm having with dates. Every time I try to type manually a date withing an equation field, it raise an error "non-matching field type". I was reading in one of your post that withing an ecuation I need to type dates in the format YYYYMMDD but even doing this it doesn't work.
My question is if this may not be working given the settings on my PC or IDEA itself, because I know that the format in wich IDEA shows me the date fields is related with the regional date setting on mi PC. Another example of this is when I put a variable within the field equation, the format (""" & variable & """) doesn't work for me, but instead the format(" & variable & ") works fine.
Here is a fragment of my code, I would be glad if you could help me with this question.
Function AppendField
Dim fech_corte As String
fec_corte = InputBox ("Select current date")
Set db = Client.OpenDatabase("Inventario_C_Resumen_VF.IMD")
Set task = db.TableManagement
Set field = db.TableDef.NewField
field.Name = "REPROC_DIAS_ATRASO"
field.Description = "Fecha corte menos fecha del 1er vto impago"
field.Type = WI_VIRT_NUM
field.Equation = "@If(FEC_1ER_VTO_IMPAGO <" & fec_corte & ";0;@Age(" & fec_corte & ";FEC_1ER_VTO_IMPAGO))"
field.Decimals = 2
task.AppendField field
task.PerformTask
Set task = Nothing
Set db = Nothing
Set field = Nothing
End Function
date format is "20201231" not
date format is "20201231" not 20201231
so please try:
field.Equation = "@If(FEC_1ER_VTO_IMPAGO <""" & fec_corte & """;0;@Age(""" & fec_corte & """;FEC_1ER_VTO_IMPAGO))"