Questions tagged [datetime]
A value that indicates a particular day and time, such as a timestamp.
740
questions
1
vote
0
answers
94
views
OutArguments to be used in journey builder (Decision box)
My CustomActivity (type- REST) returns an outArgument which is of DataType - DATE. I have configured the outArgument correctly and it is visible in the following widgets. MY customActivity is followed ...
1
vote
1
answer
260
views
Datetime Value Issue during time conversion
I have executed following code on developer console and it shows incorrect hour. Since the time used is from Seattle (Pacific time) which is 8 hours behind GMT. So when datetime.hourGMT() is used ...
0
votes
0
answers
1k
views
Display seconds in formula using date/time
How can seconds be displayed in a formula field that references a rollup summary field that calculates the MAX value of datetime field from the child objects?
The rollup summary contains a datetime ...
0
votes
1
answer
658
views
How to get week name(Week1, week2 , week3 , week4 ) or number from the month in apex function
I have a requirement to create a record on weekly basis after checking if record is not created for the previous week. how to get the week number for each month and if i am in week 2 of month than how ...
1
vote
1
answer
303
views
Changing Date time using DateTime - format(dateFormatString, timezone)
In below execute anonymous code I am seeing a strange behaviour.
DateTime myDateTime = DateTime.newInstanceGMT(2019, 12, 30, 0, 0, 0);
system.debug('myDateTime === ' + myDateTime);
DateTime ...
1
vote
1
answer
1k
views
Invalid date and time error [duplicate]
I have a @restResource that's receiving a JSON payload as a string. I am taking that payload and placing it into a Map<String, Object> variable. I'm trying to save the date/time into a variable ...
-2
votes
1
answer
1k
views
How to get the current month and use in batch apex query
I want to get the current month from picklist field and use that current month in soql query in a batch class. I have written the following code and its not working.
String month = Product.Month__c....
1
vote
2
answers
2k
views
Need help to convert the date time into EST in apex class
I have googled it but no proper solution I found it in any salesforce community.
Scenario is we are making a callout and getting the response as string value like "2018-06-12T19:00:00-07:00". Now ...
1
vote
1
answer
2k
views
Process builder conditions when custom date/time is NOW()
Should be simple but I'm getting stuck on the formula
Building a workflow in process builder and trying to trigger an action when custom object's custom date/time field is NOW().
0
votes
0
answers
526
views
Time calculation in apex
My requirement is to assign records if the lastmodifiedDate of the record falls within the employee availability. For example let's say on Sunday employee available between 8.00 AM to 5.00 PM and if ...
3
votes
1
answer
3k
views
Datetime.newInstance and Datetime.newInstanceGmt are not working correctly
My user's timezone is GMT+2 (Eastern European Time) and I notice strange thing when playing around with dates.
Date myDate = Date.newInstance(2019, 11, 29);
Time myTime = Time.newInstance(9,0,0,0);
...
0
votes
1
answer
251
views
Return of Datetime value
I am new to Apex.
I have instantiated the Datetime field with (2019, 12, 31, 12, 12, 12) where hour/minute/sec all are '12'. but in the output it is returning '20:12:12'.
Please help me to ...
0
votes
1
answer
126
views
Updating datetime field from Visualforce remoteObjects
I m trying to update a datetime field from VF page using remoteObjets and I am getting this error:
err: Error: Last Viewed Timestamp: value not of required type:
2019-11-20T11:00:56.373Z
This ...
0
votes
1
answer
181
views
DateTime.ValueOf(myString) returns date completely wrong
I'm not sure why this is happening.
When I run
System.Debug(DateTime.valueOf('2019-14-11 10:55:46 pm'));
in Execute Anonymous I'm expecting it to return the same date but in a DateTime.
However,...
1
vote
1
answer
547
views
Date formatting for SOQL String - unexpected output
I have '273' added as a day with the following line:
DateTime.newInstance(dStart.year(), dstart.month(), dstart.day()).format('DD-MM-YYYY');
so the output looks like '273-09-2019' - what gives?
I ...
1
vote
1
answer
687
views
What is the correct approach to create an Event in Apex for another User with their Timezone?
I'm trying to create an event for another user which needs to appear on their Calendar (in that user's Timezone).
e.g. Current user's Timezone is Australia/Sydney, I need to create an event for a New ...
0
votes
2
answers
2k
views
Having trouble getting DateTime Property in LWC [closed]
Trying to do a simple LWC that displays relevant fields at the top of an opportunity. But one of the fields is a DateTime field and is giving me some significant problems. When I check in the console, ...
2
votes
1
answer
6k
views
SOQL Difference Between two datetime columns
I'm trying to find all records that have a difference of 5 years between two of their columns.
A mysql example of this would be
SELECT ...
FROM custom_object__c where mydatabase_ID__c > 1 and ...
2
votes
1
answer
2k
views
Datetime conversion from date vs explicit midnight
I've just spent two days banging my head against the Salesforce wall, and the problem came down to this:
Date wkStart = Date.newInstance(2019,10,12);
Datetime wkStart1 = wkStart;
Datetime wkStart2 = ...
0
votes
0
answers
72
views
Event startDateTime shows more timestamp on Production
I have assigned custom timestamp to "starDateTime" standard field of event object by concatenating to custom date field but it shows additional 5:30 hours on Production.It works better in sandbox. I ...
2
votes
1
answer
3k
views
How to correctly convert Unix Timestamp with timezone offset into Apex Datetime?
There is a webservice which I'm trying to integrate in Salesforce. The webservice returns a date time in format like this
/Date(1569301200000-0500)/
I believe this is Unix Timestamp, and we can ...
2
votes
1
answer
127
views
MC Connector createdDate transformation
I believe there are some date transformations applied automatically when synchronizing records from SFDC to MC via the Connector
I am talking about Created-date on Contact records for instance - I ...
0
votes
1
answer
396
views
Formatting Dates and Time for SMS using AMPScript in Content Builder
Having a format issue on a SMS in Content Builder. Can someone point me to the correct code for this?
Also would love some advice to learn basic AMPScript coding. Books? Tutorials? Online classes?
...
3
votes
1
answer
6k
views
How to convert String to DateTime without time zone conversion?
I have a requirement to convert string value to DateTime without converting it to time zone.
Ex:
Datetime today = Datetime.now();
String myDate = today.format('yyyy-MM-dd HH:mm:ss');
Datetime ...
-3
votes
1
answer
1k
views
Get number of milliseconds since January 1, 1970, 00:00:00 UTC in apex [closed]
I want the apex equivalent of the following javascript method :
var utcDate3 = Date.UTC(2019, 7, 19, 18, 20, 5);
Because I need the number of milliseconds in the given Date object since January 1, ...
0
votes
0
answers
299
views
Get LanguageLocaleKey based on timezone ID
I have a custom object called Machine__c and i have a custom picklist field in it called Time_Zone__c. This Time_Zone__c field has the same picklist values as the Standard User object timezone field.
...
0
votes
0
answers
151
views
Converting String to Date
I have date format which is returned from JSON which i get in String, how do I convert it to Salesforce date format ? Does anyone have knowledge which date format is this ? Following is the date ...
0
votes
1
answer
140
views
APEX test script to web server with a static time stamp doget cakk and HttpGet
New to writing test scripts. Looking for help in error in Unexpected token 'Lead' for my test code. I have a static field that pulls off time stamp to only pull data after a certain time. I am ...
0
votes
1
answer
690
views
Invalid Date Time
While trying to retrieve the headers from an integration response, I am getting a Datetime value in String format in the Header.
Format - Mon, 01 Jul 2019 10:20:06 GMT
I need to compare this with the ...
0
votes
1
answer
813
views
Is there a way to detect actual user time zone (not Salesforce user acc.) in visualforce?
We have a "guest" form on our site, and a "guest" user to authenticate. Since the user has a set time zone, this is what (by default) is used by visualforce. Problem is, our Guest User will always be ...
0
votes
1
answer
679
views
Can someone clear up datetime time zone behavior in visualforce email template?
Between the UI on direct records automatically adjusting to my time zone and not knowing default behavior in visualforce pages, I'm having trouble wrapping my head around what the user experience ...
1
vote
0
answers
630
views
JSON time fields
We have a problem with deserialize and serialize salesforce time fields
Since Json and salesforce time fields both consist of "colon" we need to replace with a special character before deserialize ...
0
votes
1
answer
1k
views
LocalizationService formatDateTime method is not displaying correct time in European Time format
I am not getting expected output in time value. I am passing value as 20190619131800Z through query parameter and trying to format it according to Salesforce User Timezone. I am using lightning:...
0
votes
0
answers
1k
views
"INVALID_TYPE_ON_FIELD_IN_RECORD" while updating date/dateTime field using SOAP client
I have a SOAP client which connects with Salesforce and do CRUD operations.
Earlier I used to use Axis to generate stub and in that case it works perfectly but then I replaced axis with force-wsc due ...
0
votes
2
answers
6k
views
SOQL with Date filter in WHERE clause [duplicate]
@AuraEnabled
public static List<StaffReport__c> getUserReports(String UserId, Date startDate, Date endDate) {
return [Select Date__c from StaffReport__c where User__c =: UserId AND ...
0
votes
1
answer
2k
views
How to provide default DateTime value in UTC time
I am providing a default value to a DateTime field in my apex class.
customobject.DateTime__c = DateTime.parse('01/01/1990 12:00 AM');
I want to set the default value to 01/01/1990 12:00 am UTC ...
0
votes
0
answers
347
views
DateTime newInstance doesnt get in user locale
In my code I try to set datetime based on selected location. The Idea is, when the user select locale and then the time, record will be saved with selected datetime value based on selected locale. But ...
2
votes
1
answer
3k
views
onChange event is not fired for lightning:input type="datetime" when clear Time field
I have the following component:
Example.cmp
<lightning:input
aura:id="field"
type="datetime"
name="datetimeInput"
label="Set up a date/time"
...
2
votes
1
answer
1k
views
SAQL Date format conversion
I am pulling in a date field from a secondary (Japan) SFDC org into our native org. The format in the Japan org shows it as just a date (yyyy-MM-dd) but when I look at the date in the data connection ...
2
votes
1
answer
381
views
DateTime.parse doesn't take seconds or offset
DateTime.parse() won't take seconds or offsets, at least not in the US. The format from the documention in DateTime.methods() is the only one I can find that works:
Datetime dt = DateTime.parse('10/...
2
votes
1
answer
3k
views
How to Address Daylight Savings Complications when Converting Date to Date/Time?
Note: I've tagged this question with 'Apex' because there doesn't seem to be any other way to resolve it. I'm able to call on an Apex Action in a flow, but I need help with the code.
Background
My ...
0
votes
1
answer
75
views
How to compare datetime field in the format 2019-01-02 04:18:00
I have a Datetime field in Salesforce called Checkin_Date__c. I have got a list of records, then trying to compare the checkin datetime field in all the records, and want to store the recent one. But ...
1
vote
2
answers
273
views
What happens if I don't provide Time in Date/Time field
I am creating a Rest API. I have one DateTime field(one of the field for POST request). Wondering what happens if someone calls the API, makes the POST request and fills out just the Date part of the ...
0
votes
1
answer
1k
views
ISO8601 Z conversion to local date (Pacific) within SQL
I can't figure out how to take this ISO8601 date and convert it to local time (PDT).
I've tried a couple things:
convert(datetime, updated_at_text, yyyy-mm-ddThh:mi:ss.mmmZ) as LastUpdated,
convert(...
3
votes
2
answers
13k
views
Formatting Datetime.now()
I need to format my Datetime.now() to be accepted for a SOAP request.
I can't seem to find a way to format it online. Can anyone advise? I need it to look like: 2019-05-02T21:20:29.999Z
Currently I ...
7
votes
1
answer
97
views
Set collection doesn't always enforce uniqueness with the Date datatype? Does the following example seem correct?
Consider the following unit test:
@istest
public static void datetests2() {
Set<Date> dts = new Set<Date>();
dts.add(DateTime.now().Date());
dts.add(DateTime.now().addHours(1)....
0
votes
1
answer
915
views
Business Hours calculation is incorrect/ not consistent for certain dates
My use case is to calculate the deadline to respond on the Case. Rule is to add 10 business days from the complaint received date.
Defined the business hours:
Logic 1
Date initialDate = ...
1
vote
0
answers
59
views
Convert time to recipient's local time on Email marketing
I'm building an email invite to join our webinar on Marketing cloud. My recipients are based in different time zones. How can I convert my webinar time to their local time zones?
I'm using BeePro to ...
3
votes
2
answers
1k
views
I want the result of my query should be without the time and only date will be shown in result [closed]
Select Id, CreatedDate From Opportunity Where DAY_ONLY(CreatedDate)
this the query I used but result is still with time
0
votes
1
answer
1k
views
Not getting the right time in apex
DateTime.now() return time stamp which is 10 hours more than the current time, I am currently using the Hawaii standard time please find below the snippet now current time is 6:11 am but if I use ...