You need to sign in to do that
Don't have an account?
Milan Hrdlicka
Insertion of datetime
Hi all,
I need to insert datetime using below code:
Opening_Hours__c oh = new Opening_Hours__c(Name='3', Open__c=2016-12-27T08:00:00Z);
insert oh;
I get this error: "unexpected token: "2016-12-27T08:00:00Z"
Can you please advise on what I am doing wrong?
How can I make a distinction in case of "AM" and "PM"?
Open__c is a field of datewtime type. Thanks a lot.
I need to insert datetime using below code:
Opening_Hours__c oh = new Opening_Hours__c(Name='3', Open__c=2016-12-27T08:00:00Z);
insert oh;
I get this error: "unexpected token: "2016-12-27T08:00:00Z"
Can you please advise on what I am doing wrong?
How can I make a distinction in case of "AM" and "PM"?
Open__c is a field of datewtime type. Thanks a lot.
1) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_date.htm
Opening_Hours__c oh = new Opening_Hours__c();
oh.Name='3';
oh.Open__c=System.now();
insert oh;
****************
The specified string should use the standard date format “yyyy-MM-dd HH:mm:ss” in the local time zone.
DateTime myDateTime = DateTime.newInstance(2016, 12, 27, 8, 0, 16);
Opening_Hours__c oh = new Opening_Hours__c();
oh.Name='3';
oh.Open__c=myDateTime;
insert oh;
Let us know if this will help you
All Answers
1) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_date.htm
Opening_Hours__c oh = new Opening_Hours__c();
oh.Name='3';
oh.Open__c=System.now();
insert oh;
****************
The specified string should use the standard date format “yyyy-MM-dd HH:mm:ss” in the local time zone.
DateTime myDateTime = DateTime.newInstance(2016, 12, 27, 8, 0, 16);
Opening_Hours__c oh = new Opening_Hours__c();
oh.Name='3';
oh.Open__c=myDateTime;
insert oh;
Let us know if this will help you