datetime - how to compare the dates in different format with the getdate() in sql server -


i have column, date values stored in nvarchar data type. date format dd-mm-yy, dd.mm.yy

currently replacing - . , comparing date, dates formats used in other tables in dd.mm.yyyy format.

now consider scenario dates may in other formats dd/mm/yyyy or other date formats, there way check whether date valid , compare getdate()

also find few unknown records available 57937234, need ignore them.

as of using query , working fine:

select      a.value, replace( b.value,'-','.')       smpltbl inner join      smpltbl b on a.mskey = b.mskey inner join      smpltbl tbl_status on a.mskey = tbl_status.mskey      a.colname = 'xyz'      , b.colname = 'abc'      , tbl_status.colname = 'status'      , tbl_status.value = 'ok'     , b.value <> '00.00.0000'      , b.value <>'..'      , replace( b.value,'-','.') < cast(convert(nvarchar, getdate(), 104) 

can kindly me in accepting dates in different format comparing system date , result must displayed in dd.mm.yyyy format itself

depends on version of sql server using can have different solutions.

convert(varchar(10), getdate(), 103) 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -