Questions tagged [date]

A value that indicates a particular day. Unlike Datetime values, Date values contain no information about time

Filter by
Sorted by
Tagged with
43
votes
7answers
29k views

How Can I Tell the Day of the Week of a Date?

I'd like to build in some logic based on the weekday (e.g. Monday, Tuesday, Wednesday) of a given date. How can I identify the date, using either formulas or Apex code?
14
votes
3answers
28k views

How to calculate the time between two DateTimes?

I know that you can use daysBetween() for two Date objects, but what would I use to calculate the elapse time in seconds between two DateTime objects?
3
votes
1answer
938 views

Is there anyway to get in DD/MM/YYYY or MM/DD/YYYY format

I just querying Date field and assign value in date variable //Date variable public Date arrivalDate {get;set;} now I am quering date field and assigning value in variable arrivalDate = QueryField; ...
14
votes
2answers
7k views

System vs Date/DateTime class

Is there any difference between System.today() and Date.today()? Similarly, is there any difference between System.now() and DateTime.now()?
4
votes
1answer
500 views

Duration as difference betweed to Datetime fields does not respect Seconds

It seems that Seconds are ignored in formula fields if you create the difference between Datetime/Time fields. Say you have two Datetime fields: End__c and Start__c Take a formula field Duration__c (...
3
votes
3answers
7k views

Date Formula to Calculate date excluding weekends

I have a formula that is calculating the date from another date field + number of days and returning a date. test census dates field = Confirmed_Enrolled_Date__c + 16 I want to exclude weekends ...
4
votes
2answers
2k views

Invalid Date format from Database

Trying to insert a Contact from an Oracle Database: Contact Database Entity: @Temporal(TemporalType.DATE) @Column(name="DOB") private Date dob; Contact SOAP SObject set Birthday: Calendar ...
0
votes
3answers
3k views

How to remove time from date?

The following code returns the time of the current date: System.debug('Current date: ' + Date.today().toStartOfMonth()); Output: 2018-08-01 00:00:00 How to remove time from date?
7
votes
2answers
883 views

DateTime.Format() Documentation example causes exception

I'm trying to get a DateTime to format into a value to be used in a dynamic query. For some reason, the documentation snippet on how to format a DateTime for a query is giving me an exception. Im ...
6
votes
3answers
12k views

Lightning:input type=“date”: how to change the date fomat - Summer'18

I'm trying to change date format of this component but I dont find any attribute (like ui:inputDate has) to change the date format. <lightning:input type="date" name="input8" label="Dates" value="...
3
votes
4answers
3k views

Formula that returns the current day of the week

In Salesforce Trailhead there is one Challenge available. Please find the challenge description below To complete this challenge, use some of the strategies and function you learned in this unit to ...
2
votes
3answers
1k views

Number of weeks between dates

I have two Date values. I need to find number of weeks between them. I want to do it Apex Class. Not looking for formula fields. So far I tried: Integer numberofweeks = (projectStartDate - opp....
0
votes
1answer
189 views

Extract logindate from user object and populate a new field in a custom object via batch apex

I would like to apologise if any spelling mistakes , in currently posting this on an iPhone whilst I commute home I found a link online which I think meets my requirements As we are all aware ...
7
votes
1answer
7k views

Convert Date to milliseconds and milliseconds to Date

I am getting date into JSON as below : date=1382166999 It seems that date has been returned in milliseconds format. Can anyone please suggest the way to convert it into normal date format and vice ...
6
votes
1answer
10k views

Displaying date in visualforce force page in required format

I have a date fields which on displaying on VF page displays like 12/10/2012. But i want to display it like December 10, 2012. How can i do it? i am not getting the easy way.
5
votes
2answers
10k views

Date is showing a different date than the Date/Time Field

I have an issue when entering a date/time into a date field where the date increases by 1 day when after a certain time. Example would be 1/1/13 5:23PM PST converting to 1/2/13. This also occurs ...
4
votes
2answers
2k views

Apex: Date/DateTime.parse or valueOf string gets error

I've got a date string coming in like so: String str = 'Thu Jan 14 2016 23:29:58 GMT+1100 (AEDT)' It's always in that format, but neither Date nor DateTime can .parse or take .valueOf the string. ...
3
votes
1answer
856 views

Is it possible to make apex:input “locale aware”?

I want to use the fairly new input types that HTML5 defines. In Salesforce, the different types are: date, datetime, datetime-local, month, week, time, email, number, range, search, tel, text, and url....
2
votes
3answers
3k views

Excluding weekend and holidays from my days number

I want to retreive the weekend and holidays from my days number! I've created a formula field named weekend where I put : CASE(MOD( Start_date__c - DATE(1985,6,24),7), 0 , CASE( MOD( End_date__c - ...
2
votes
1answer
2k views

How to calculate duration between two dates(in months and days) using formula field?

My client wants me to write a formula field to return the duration(in months and days) between two date fields. For ex: If start date is "January 1st 2016" and end date as "December 31st 2016" then ...
11
votes
4answers
2k views

Datepicker widget location issue

I have a visualforce page with a standard controller of a custom object, and within the page and inputfield that is tied to a custom date field of said object. I've dropped the VF page into the page ...
3
votes
3answers
1k views

Issue with Jquery DatePicker in Visualforce page

I have been facing an issue with the usage of datepicker in my VF page. VF page: <script> jQuery(function(){ var $j = jQuery.noConflict(); $j("input[id$=expdate]...
7
votes
3answers
5k views

Get list of Date locales

It is possible to change the locales used for Date for users in the Admin. For example, Ireland is dd/mmy/yy The US is m/d/yyyy Is there anywhere where I can get a list of all locales? Thanks
7
votes
1answer
22k views

Convert DateTime to Date

I want to Convert DateTime into Date I have been trying this out ..below is the code snippet public void searchSFDC() { DateTime lastModDate ; for(sObject resultSet : searchResults[0]) { // ...
6
votes
1answer
1k views

URL hacking a report to pass a Date Literal filter value vs an actual date

Though not well documented by Salesforce, it's a well known fact that record pages and saved reports can be dynamically altered by passing URL parameters. For example, with a tabular report whose ...
4
votes
3answers
245 views

Deserialising a DateString

I do: Date d = (Date)JSON.deserialize('2013-06-07T00:00:00.000Z', Date.class); System.debug('**********d = ' + d); I expect: *************d = 2013-06-07 00:00:00 I see: *************d = 2013-01-...
4
votes
1answer
5k views

How to convert date time to date

On a http call response i was getting date as 1970-01-08T23:45:27.461Z. Here i have to change it to date like 1970-01-08 ... need some ideas... when i tried to take Date type in wrapper classes ...
3
votes
1answer
5k views

How to add days to a date field that spans over a year?

I have a field called: Payment terms ( holds values as: 30, 60, Net 30, Net 60..) which defines that payment due date of an oppty. Payment due date is a Date field, with default value of: Today(). I ...
2
votes
1answer
116 views

DateTime Vs. Date Flow To ProcessPlugin

I find this to be odd, not sure if this is a known issue or if it is something I just have to convert but I have a flow that calls a apex process plugin class. The flow takes a variable of type Date ...
2
votes
3answers
10k views

How to Get the Current System Time using SOQL

For tests proposes, I need to get the current system date. On Oracle we could use: SELECT SYSDATE FROM DUAL On SQL SERVER, we can use: SELECT GETDATE() AS CurrentDateTime How to query the system ...
2
votes
2answers
1k views

Java sql.TimeStamp to Salesforce

I have a Java mapping that takes a field of type java.sql.Timestamp and insert it into Salesforce. Example of a field in the db: 2013-10-17 13:01:01 When it is inserted into Salesforce it looks ...
1
vote
4answers
1k views

Formula Question: Record a date of first activity on contact object

I need to create a custom field on my Contact object that records the date of the very first call that has happened with a Contact record. I thought about creating a formula field on Contact, and ...
1
vote
1answer
2k views

BestPractice: Displaying Months on Visualforce Page

Is this a good practice in displaying months? Code Snippet: <b>{!CASE( IF( (MONTH(TODAY()) +3) > 12, (MONTH(TODAY()) +3) - 12, MONTH(TODAY()) +3), ...
0
votes
1answer
121 views

String parse to Date yyyymmdd

I need to parse a string that I got from a json to date while the value of the string is in the next format: yyyymmdd - for example 20190429. Is there another simple way to do it instead doing ...
0
votes
2answers
790 views

Date format from Apex variable in VF

apex:variable var="Expiry" value="{!if((TEXT(object.Executed_Expiry_Date__c)!=null && TEXT(object.Executed_Expiry_Date__c)!=''),object.Executed_Expiry_Date__c, object.Expiry__c)}" ...
0
votes
1answer
40 views

Formula for assigning a value to all working days between 2 dates

I am logging Sickness in salesforce and have a start and end date. For reporting purposes i need to be able to assign a 1 to each of the working days between these 2 dates. Then when i report i can ...
0
votes
1answer
4k views

Using Date in SOQL to get only records created on a certain date

I'm using this soql query in my webservice to query for records created within specific dates and using this as an if condition of the dates are the same if(fromDate == toDate){ orderList = ...
-3
votes
1answer
118 views

calculating Date in salesforce [closed]

I have 2 fields Day of year, Date of year. I want the logic to be build as If i enter day of year = 50 In date field i should get as 19/02/2015 50 th day of year is 19th Feb. This should change ...