Questions tagged [datetime]

A value that indicates a particular day and time, such as a timestamp.

Filter by
Sorted by
Tagged with
3
votes
1answer
26 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
1answer
22 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
1answer
13 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
1answer
25 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
1answer
25 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
1answer
38 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
2answers
48 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, ...
0
votes
1answer
21 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
1answer
48 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
0answers
36 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
1answer
101 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
1answer
35 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
1answer
51 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
1answer
57 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
1answer
42 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
0answers
23 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
0answers
39 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
1answer
43 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
0answers
58 views

SQL to post + 30 days by Date/Time attribute

Goal is to find rows where the date is exactly 30 days from today. Source is a Salesforce Date/Time field from a Synchronised Data Extension and posted to a regular Data Extension to Date attribute. ...
0
votes
1answer
50 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
1answer
34 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
1answer
29 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
0answers
76 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
1answer
108 views

How to disable the blue border around all the element after selecting a time in lightning:input of type datetime?

I have a lightning:input of type datetime When I select a date it's ok, but when I select a time, after selecting during this "click" it's showing like a blue border around all the element. I know ...
0
votes
1answer
189 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
0answers
189 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
3answers
195 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 Date__c &...
0
votes
1answer
87 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
0answers
32 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
1answer
194 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" ...
1
vote
0answers
103 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
1answer
33 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/...
1
vote
1answer
173 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
1answer
38 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
2answers
50 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
1answer
51 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(...
1
vote
2answers
562 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
1answer
90 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
1answer
77 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
0answers
28 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 ...
0
votes
2answers
37 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
1answer
43 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 ...
1
vote
1answer
157 views

Compare DateTime in Apex

I have created 2 dateTime Instances as below to compare DateTime.now() if it is greater than 8 pm and less than 7:59 am then I want to execute some code but it is difficult to compare dateTime as the ...
0
votes
0answers
29 views

ISO 8601 date/time parsing incorrectly from API input

I have a REST API pushing data into a Marketing Cloud data extension and SFMC appears to be transforming it to the system date/time vs the original input from the API. eg. I have a record with an ...
0
votes
1answer
64 views

DateTime field value in Text formula

I have a DateTime field which shows proper time on UI, I know behind the scene it is GMT format. However I would like to populate same format as it displays on UI in a text field along with some text.
0
votes
1answer
515 views

Convert 24 hours date time to 12 hours date time format

I need to convert and assign 24 hours date time value to custom date time field. For Example, in my apex code I am getting the date time value as ‘2019-03-12 14:38:00’, I need to convert and assign ...
1
vote
1answer
42 views

Get the Hour from a date time field with the current time zone in a formula field

I create a custom field to display the hour and the minute of a date time field. The format I need is HH:MM For now, I get the hour in GMT but it is wrong because I am in France and the time zone ...
1
vote
0answers
21 views

How to get records created between timeframe in a report

I need to create a report of all the records between 7am to 5pm CST/CDT everyday. How can I achieve this? The solution I tried - Created a formula field which extracts Hours from created date (...
0
votes
1answer
417 views

SOQL DateTime Greater than Date

For the life of me I cannot figure out how to query tasks greater than a given DateTime. I have a field, inqDateTime, that I need to pull tasks greater than that date. I have tried to convert the ...
0
votes
1answer
43 views

How to Parse date time String to DateTime using Apex

Given this string value: String dateTimeString = '20/12/18 16:39:51'; // or '31/10/18 09:35:16' How would I parse it to a DateTime? I've tried this: DateTime dt = DateTime.parse(dateTimeString); ...