Tuesday, 27 August 2013

Parse date into dd-MMM-yy

Parse date into dd-MMM-yy

Friends...
IN my ms access database i store date format dd-MMM-yy. and in search
query pass dates as parameter. but my system cantain date format
mm/dd/yyyy so,how can i convert this format in dd-MMM-yy before pass this
date to query now,i m using folling code..but give error....String was not
recognized as a valid DateTime.
DateTime dt = DateTime.ParseExact(startdate.ToString(), "dd-MMM-yy",
CultureInfo.InvariantCulture);//startdate is datepicker
query...
s = new OleDbDataAdapter("SELECT opd_patient_master.*, patient_operation.*
FROM opd_patient_master, patient_operation where opd_patient_master.pid=
patient_operation.pid and opd_patient_master.rdid=
patient_operation.rdid and odate >= #" + startdate + "# and odate<=# " +
enddate + "# and operation= '" + oprtype + "'", mycon);
friends..Plz give me helping hands.. Thanks..

No comments:

Post a Comment