Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 887

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

4 votes
Accepted

Is this a bug in Apex DateTime.format?

Duh NO. Some more Googling reveals this answer from a different language: Difference between 'YYYY' and 'yyyy' in NSDateFormatter that can be summarized as: use yyyy not YYYY and that fixes the prob …
Keith C's user avatar
  • 137k
29 votes

Convert DateTime to Date

Datetime objects have this date method: date() Returns the Date component of a Datetime in the local time zone of the context user. … so your code can use it like this: Datetime dt = (Datetime) resultSet.get('LastModifiedDate'); sf.lastModifiedDate = dt.date(); (Generally you would need a null check in the code but as LastModifiedDate …
Victor Lockwood's user avatar
3 votes

Return of Datetime value

The mechanism helps when orgs have users working in multiple timezones See the various Datetime Class methods that output with and without this conversion. …
Keith C's user avatar
  • 137k
2 votes
Accepted

DateTime values in Bulk Query results - difference between CSV and JSON formats

Most APIs can convert such a value to an appropriate DateTime object. … In Apex it is: Long longtime = 1341828183000L; DateTime dt = DateTime.newInstance(longtime); DateTime expected = DateTime.newInstance(2012, 7, 09, 3, 3, 3); System.assertEquals(expected, dt); …
Keith C's user avatar
  • 137k
1 vote

Create a new Record on New object by comparing Queries

PurchaseDate = Purchaselist[i].createddate; Datetime Recommendate = RecommendationList[j].createddate; .. … PurchaseDate = p.createddate; Datetime Recommendate = r.createddate; ... …
Keith C's user avatar
  • 137k
0 votes

How to select multiple sets of consecutive data/rows based on time using SOQL?

How about this Apex: DateTime start = ...; DateTime end = start.addMinutes(90); Availability__c[] slots = [ select ... …
Keith C's user avatar
  • 137k
2 votes

Converting a datetime string type to datetime type in apex

For your example the DateTime converter is getting used. …
Community's user avatar
  • 1
2 votes
Accepted

JSON.deserialize adding time

DateTime supports the presentation of the Date/Time in both GMT and in the time zone of the User. Is the User you are testing under in a time zone that is 4 hours different from GMT? …
Keith C's user avatar
  • 137k
1 vote

Convert Primitive dateTime to dateTime class

Note however that DateTime database fields do not preserve milliseconds, so you would need to consider that in your test logic. …
Keith C's user avatar
  • 137k
1 vote

Date field is also giving me time

If you bind the date field into the query rather than make it part of the query string you will avoid this problem. So your query string becomes: queryString = 'SELECT id, Name FROM SObject WHERE da …
Keith C's user avatar
  • 137k
1 vote

SOQL query to fetch incremental data hourly

In SOQL there is a built in syntax for LAST_N_DAYS, but for this case your will have to construct a date literal string (see Date Formats and Date Literals) so your query becomes e.g.: SELECT Id, ... …
Keith C's user avatar
  • 137k
0 votes
Accepted

Need to Filter a VF page with date input and pass to SOQL statement in controller

AND CreatedDate <= :taskRec1.ActivityDateTime_del__c ]; } } so that when the page refreshes after the "Submit" is clicked the data is filtered using the current datetime
Keith C's user avatar
  • 137k
8 votes

Create a new date

This looks like poor error reporting by the compiler; the signature required is: DateTime.newInstance(Integer, Integer, Integer, Integer, Integer, Integer) so your local variables need to change to …
Keith C's user avatar
  • 137k
2 votes

javascript date on custom button issue..?

The client (browser) and server (salesforce) are unlikely to be set to the same timezone. The clean solution to that problem is to avoid it and just use the server timezone. If you have control over …
Keith C's user avatar
  • 137k