Sunday, March 11, 2012

Conditional Split - Compare DATETIME with constant

Hi,

I have to compare a DATETIME Field with '1/1/1900 12:00:00 AM". Which is default DATE TIME Value in SQL Server.

I did compare like

TRADEAGREEMENTFROMDATE != (DT_DBTIMESTAMP)(DATEPART("mm",(DT_DBTIMESTAMP)"1/1/1900 12:00:00 AM"))

but (DT_DBTIMESTAMP)(DATEPART("mm",(DT_DBTIMESTAMP)"1/1/1900 12:00:00 AM")) returns "12/31/1800 12:00:00:AM"

Thanks,

Aravind

So the value I got was slightly different.

(DT_DBTIMESTAMP)(DATEPART("mm",(DT_DBTIMESTAMP)"1/1/1900 12:00:00 AM")) = 31/12/1899 00:00:00

Why are you using DATEPART? Do you not just want -

(DT_DBTIMESTAMP)"1/1/1900" = 01/01/1900 00:00:00

That is the same as '1/1/1900 12:00:00 AM' which you asked for above, infact the time format is just my local settings UK rather than US, the values are exactly the same.

No comments:

Post a Comment