vb.net - DevExpress Report Label FormatString not working for Date -


i've been stuck trying solve problem few days ago no result, appreciated.

i retrieve date field database in format (dd/mm/yyyy hh:nn:ss am/pm) keep sorting , other purposes, , want display format in xtrareport in format (dd/mm/yyyy)

details: developing vb.net project includes devexpress reports. problem xtrareport includes date field among data, binding report's labels empty datatable in project's dataset, , fill datatable , bind report datatable in runtime. works great except using label's smarttag edit formatstring property doesn't seem have effect output result. please note don't want change source sql query format.

thanks, mohamed

if database return column values of datetime type can use binding.format set format of values.
here example:

dim datatable new datatable("data") datatable.columns.add("datetime", type.gettype("system.datetime"))  datatable.rows.add(new datetime(2003, 10, 5, 19, 12, 15)) datatable.rows.add(new datetime(1987, 1, 4, 11, 47, 53)) datatable.rows.add(new datetime(2010, 6, 25, 7, 25, 14))  dim label new xrlabel() label.databindings.add(new xrbinding("text", nothing, "datetime", "{0:dd'/'mm'/'yyyy}"))  dim detail new detailband() detail.controls.add(label)  dim report new xtrareport() report.bands.add(detail)  report.datasource = datatable  dim tool new reportprinttool(report) tool.showribbonpreview() 

if database return column values of string type can use calculatedfield , substring function in expression.
here example:

dim datatable new datatable("data") datatable.columns.add("datetimestring", type.gettype("system.string"))  datatable.rows.add("05/10/2003 19:12:15") datatable.rows.add("04/01/1987 11:47:53") datatable.rows.add("25/06/2010 07:25:14")  dim calculatedfield new calculatedfield() calculatedfield.name = "datetime" calculatedfield.expression = "substring(datetimestring,0,10)"  dim label new xrlabel() label.databindings.add(new xrbinding("text", nothing, "datetime"))  dim detail new detailband() detail.controls.add(label)  dim report new xtrareport() report.bands.add(detail)  report.datasource = datatable  report.calculatedfields.add(calculatedfield)  dim tool new reportprinttool(report) tool.showribbonpreview() 

the result:
the result


Comments

  1. I just want to let you know that I just check out your site and I find it very interesting and informative.. http://psiprograms.com

    ReplyDelete

Post a Comment

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Socket.connect doesn't throw exception in Android -

SPSS keyboard combination alters encoding -