function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
lapaullapaul 

Seperate Date/Time field into date and time

Hi,

I have a custom date/time field and I want to seperate it into date and time fields. It would look similar

to the new events in Salesforce calendar. However I don't know how to do this. Does anyone have

sample codes or tips on this issue? Any help will be appreciated.

 

thanks

Paul

 

AKallAKall

Hi lapaul,

I have recently found a need for something similar. Did you ever find a solution to this?

 

Thanks,

akall

lapaullapaul

 

Bbasically you need to write a routine to do this seperation. Below is a routine to parse time string.

Hope this helps.

 

 

private Time ParseTime(String strTime) {

Integer TM_H;

Integer TM_M;

String TM_AP;

String[] tmp;

 

tmp = strTime.split(':', 2);

TM_H = Integer.valueOf(tmp[0]);

tmp = tmp[1].split(' ', 2);

TM_M = Integer.valueOf(tmp[0]);

TM_AP = tmp[1];

 return Time.newInstance(TM_H + (TM_AP.startsWith('P') ? 12 : 0), TM_M, 0, 0);

}