how to assign a date to a datenull() filed

hi…

if the field is null means,i want to assign a date to that field…

i want to assign the min date (1,1,1900)

how to do it???

if(DOB == datenull)

{

//wht to write???

}

can anyone help me pls…

thanx in advance

where you are writing this code and for which purpose?

can you explain briefly about this then you can find the best solution…:slight_smile:

Have you ever opened dateNull() method? Here it is:

static date dateNull()
{
    return 01\01\1900;
}

AX doesn’t allow to assign null to date fields, it simply uses 01\01\1900 as a default value. If you check the field for dateNull() value (= 01\01\1900), there is no point in assigning the same value again.

hi venkadesh,

am checking the date field, if its have data means its enter into the loop,

if its null means, i want to assign the date to that filed then oly shd enter into the loop…

thanx :slight_smile:

Hi,

You are almost there. Try this -

if (DOB == datenull())
{

}

hi harish…

i want to do like this,

if (DOB == datenull())

{

cnk.DOB=1/1/1900;

} if i did like this means its shows error…

hi arun,

if you write like if(DOB==datenull()), if the date is there it will consider that date otherwise it will assign default date that is 1900/01/01 to that date. there is no need to assign default date explicitly.

by writing the above code even if the date is not available also it will enter into the loop with default date…