You need to sign in to do that
Don't have an account?

DateTime To Date Conversion Apex
I want to convert DateTime Value to Date Value , Please help me out ????????????
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Here is some psuedo-code:
DateTime dT = System.now();
Date myDate = date.newinstance(dT.year(), dT.month(), dT.day());
All Answers
Here is some psuedo-code:
DateTime dT = System.now();
Date myDate = date.newinstance(dT.year(), dT.month(), dT.day());
iam still getting the time value but it set to 00;0:0
can we make this time value excluded?
Please help me any help is greatly appreciated.
Thanks
Bhanu
Hi Bhanu,
try this. I was getting same issue but this resolved my problem...
string datetimestr = LastRunDate.format('MMMMM dd, yyyy');
this gives you date in this format:------- May 03, 2012
If you need more formatting on dates and times please follow this link
http://paulforce.wordpress.com/2009/08/27/formatting-time-in-apex/
public String sdate {get;set;}
DateTime dT = System.now();
myDate = date.newinstance(dT.year(), dT.month(), dT.day());
sdate = String.valueOfmyDate);
Now it's displaying Only Date
Convert Datetime to Date
Public Date mydate{get;set;}
public String sdate {get;set;}
DateTime dT = System.now();
myDate = date.newinstance(dT.year(), dT.month(), dT.day());
sdate = String.valueOfmyDate);
Now it's displaying Only Date
DateTime dt = System.now()
Date d = dt.date();
System.debug(d);
System.debug('Local Date is....: '+system.now().year()+'-'+system.now().month()+'-'+system.now().day());
system.debug('Local Time is....: '+System.now().hour()+':'+system.now().minute()+':'+system.now().second()+':'+system.now().millisecond());
Date todaysDate = system.today();
OR use DateTime class
Date todaysDate = datetime.date();
DateTime tDateTime = datetime.now();
tDateTime = tDateTime.addHours(9);
tDateTime = tDateTime.addMinutes(30);
DateTime dT = system.now()
Date myDate = date.newinstance(dT.year(), dT.month(), dT.day());
String datevalue = String.valueOf(myDate);
Thanks,
shashikant
news blogHi,
Thanks
DateTime myDateTime = system.now();
Date myDate = myDateTime.date(); (or) myDateTime.dateGMT();