[#BloombergLP-bdlt-Datetime-setDatetimeIfValid-02] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlt.adoc[bdlt]::xref:BloombergLP/bdlt/Datetime.adoc[Datetime]::setDatetimeIfValid :relfileprefix: ../../../ :mrdocs: Set the value of this object to a `Datetime` whose "date" part has the value represented by the specified `date`, and whose "time" part has the value represented by the optionally specified `hour`, `minute`, `second`, `millisecond`, and `microsecond` attributes, if the attribute values (collectively) represent a valid `Datetime` value (see `isValid`). Unspecified trailing optional parameters default to 0. Return 0 on success, and a non‐zero value (with no effect) otherwise. == Synopsis Declared in `<bdlt_datetime.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- int setDatetimeIfValid( xref:BloombergLP/bdlt/Date.adoc[Date] const& date, int hour = 0, int minute = 0, int second = 0, int millisecond = 0, int microsecond = 0); ---- [.small]#Created with https://www.mrdocs.com[MrDocs]#