You need to sign in to do that
Don't have an account?
Surender
Remove the timestamp from the DateField Value
Hi,
Can someone guide us like how can we remove the timestamp from the DateField Value.
Ex: Suppose i have Date value like 2011-11-15 00:00:00 then i want to print only 2011-11-15.
Please share your thoughts on this.
Regards
G. Surender
Datetime dateTimetemp = System.now();
System.debug('Before Date String'+dateTimetemp);
Date dateTemp = Date.newInstance(dateTimetemp.year(),dateTimetemp.month(),dateTimetemp.day());
System.debug('After Date String'+dateTemp);
String x=dateTemp.format();
system.debug('xxxx'+x);
Try this...
All Answers
Try this
Datetime dateTimetemp = System.now();
Date dateTemp = Date.newInstance(dateTimetemp.year(),dateTimetemp.month(),dateTimetemp.day());
Hi,
I tried the above like
Datetime dateTimetemp = System.now();
System.debug('Before Date String'+dateTimetemp);
Date dateTemp = Date.newInstance(dateTimetemp.year(),dateTimetemp.month(),dateTimetemp.day());
System.debug('After Date String'+dateTemp);
Output:-
Before Date String2011-12-02 05:37:11
After Date String2011-12-01 00:00:00
In the output still am getting the timestamp values(as zeros), but i don't want to display them.
Can you please reply.
Regards
G. Surender
Datetime dateTimetemp = System.now();
System.debug('Before Date String'+dateTimetemp);
Date dateTemp = Date.newInstance(dateTimetemp.year(),dateTimetemp.month(),dateTimetemp.day());
System.debug('After Date String'+dateTemp);
String x=dateTemp.format();
system.debug('xxxx'+x);
Try this...
Thanks it worked for me..
can you please tell what you did to get it work? I am still getting time with Zero's
Thanks