0

m trying to UPDATE :

IF @usmsopt == "False" THEN
  SET @smsoptoutdate = CURRENT DATE
ELSE
  SET @smsoptoutdate = CLEAR THE DATE

ENDIF

with the following AMP:

IF @usmsopt == "False" THEN
  SET @smsoptoutdate = Now()
ELSE
 SET @smsoptoutdate = ""
ENDIF

BUT WHEN @usmsopt == "True" then instead of emptying the field i get '1/1/1900 12:00:00 AM' value

any idea??

How about if i do like below ??: based on this:https://code.exacttarget.com/question/forcing-date-field-remain-null

IF @usmsopt == "False" THEN

  SET @smsoptoutdate = Now()

ELSE

 ENDIF

THE ABOVE (1) WORKED WELL FOR ME FOR CREATE OPERATION . BUT AM TRYING TO WORK STILL ON UPDATE WITHOUT TRYING TO CHANGE THE DATE FIELD AS TEXT IN DE . BASED ON THE LINK : https://code.exacttarget.com/question/end-date-field-getting-default-value

DOES THE FOLLOWING WORK (update an existing value to NULL):

/* to do : here i need to clear the old optout date */
ELSEIF @currentsmsopt == "True" AND @presmsopt =="False" THEN
IF NOT EMPTY(@presmsoptdt) THEN 
Var @deo
Set @deo = CreateObject("DataExtensionObject")
SetObjectProperty(@de, "CustomerKey", "DATA EXTENSION")
/*   erase the exsting value */
Var @smsoptoutdateproperty
Set @smsoptoutdateproperty = CreateObject("NullAPIProperty")
SetObjectProperty(@enddateproperty, "Name", "smsoptoutdt")

AddObjectArrayItem(@deo, "Properties", @smsoptoutdateproperty)

SET @result = UpsertData("DATA EXTENSION", 1, "custid", @ucustid, "emailaddress", @uemailaddress, "FirstName", @ufirstname, "LastName", @ulastname, "Zip", @uzip, "Mobile", @mobile1, "Phone", @phone, "Country", @ucountry, "Wants_email", @uemailopt, "Wants_sms", @currentsmsopt, "Add_Edit_Date", @editdt, "Optoutdate_sms", @smsoptoutdt, "Optoutdate_email", @emailoptoutdt, "Mobilecode", @countrycode, "Locale", @ulocale, "Signup", @signupdt, "Source", @source, "SubscriberKey", @friendkey)
ENDIF
ENDIF

2 Answers 2

3

The default time stamp in a data extension is the '1/1/1900 12:00:00 AM' value you are seeing.

In order to not get that, you would need to have the field set to a text field. This should correct your issue. The data will still be recognized in other parts of the program as a date, even though the field type is not set to date.

9
  • Any workaround solution without touching the DE field type ??
    – Jack85
    Commented Apr 29, 2014 at 7:26
  • 1
    No, unfortunately. Commented Apr 29, 2014 at 8:54
  • How about if i try sth like above ? is it acceptable??
    – Jack85
    Commented May 23, 2014 at 8:51
  • a moment to have a look on this?
    – Jack85
    Commented May 27, 2014 at 13:21
  • 1
    @Jack85 - that should work for you. Give it a shot and let me know how it goes. Commented May 27, 2014 at 13:24
2

A bit of an old post but updating can be accomplished by pulling a reference value via a lookup then using that value to set the date in a target DE.

%%[
/* Lookup reference null value of dateStamp from ID=1 */
SET @n = Lookup('NullDateTest', 'dateStamp', 'ID', '1')
/* show that ID 2 has a value */
SET @n2 = Lookup('NullDateTest', 'dateStamp', 'ID', '2')
OUTPUT(concat("n1: ",@n, " n2: ", @n2, "<br>"))
]%%

%%[
/* show updated row count */

OUTPUT(UpdateData('NullDateTest', 1, 'ID', '2', 'dateStamp', @n))

]%%

%%[
/* show final values where date has been updated to null */
SET @n3 = Lookup('NullDateTest', 'dateStamp', 'ID', '1')
/* Used a lookup rows to prevent cached result of a lookup */
SET @n4 = Field(Row(LookupRows('NullDateTest', 'ID', '2'), 1), 'dateStamp')
OUTPUT(concat("<br>n3: ",@n3, " n4: ", @n4))
]%%

Oddly you cannot use a similar tactic directly in SSJS, perhaps because the way the concept of null works in SSJS but you can use an AMPscript var to perform the same action in SSJS.

%%[
/** reference null value pulled into Variable **/
SET @n = Lookup('NullDateTest', 'dateStamp', 'ID', '1')
]%%
<script runat=server>
Platform.Load("core", "1");
var DE = DataExtension.Init("NullDateTest");
DE.Rows.Update({dateStamp:Variable.GetValue("@n")}, ["ID"], ["2"]);
</script>
1
  • Thanks Brandt! This does work and accomplished my requested task. Note (which may not be surprising): some functions performed could alter the value being written back. Example, if you try to assign the value from an iif statement, like: set @datestamp = iif (1==1, field(@row,'datestamp'), @datestamp)) This will upsert or update back to the DE with 1/1/1900. "If, then" will not cause it when it is doing its evaluation. Just something to be aware.
    – Mark_F
    Commented Aug 19, 2019 at 17:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .