I have a datepicker that needs to take the date &quot;12/31/9999&quot; even though maxDate is set to today.  I have it type in like this. However, when I run the comparison in the code, it returns false. private CheckDate(form: FormGroup, group: any) {      if (form.controls[&quot;date&quot;].value == new Date(&quot;12/31/9999&quot;)) {          //form.controls[&quot;date&quot;].valid = true;          (group.questions[&quot;date&quot;] as DateTimePickerQuestion).maxDate = null;      } }  However, when I compare form.controls[&quot;date&quot;].value to new Date(&quot;12/31/9999&quot;) it comes back as false and doesn't execute my code in the middle. Why is that? Here is a copy/paste of the immediate window checking the values new Date(&quot;12/31/9999&quot;) Fri Dec 31 9999 00:00:00 GMT-0500 (Eastern Standard Time) {} form.controls[&quot;date&quot;].value Fri Dec 31 9999 00:00:00 GMT-0500 (Eastern Standard Time) {} form.controls[&quot;date&quot;].value == new Date(&quot;12/31/9999&quot;) false
673
Can someone suggest a way to compare the values of two dates greater than, less than, and not in the past using JavaScript? The values will be coming from text boxes.
80895
Why does this javascript return 108 instead of 2008? it gets the day and month correct but not the year?  myDate = new Date(); year = myDate.getYear();   year = 108?
9505
Let me explain you the problem   $ date +%c -d "$d" Tue 31 Dec 2013 01:13:06 PM CET $ date +'Today is %F' -d "$d" Today is 2013-12-31   This solution corresponds to current date.  But I have one variable which stores date other than current date  $Prev_date="Wed Dec 25 06:35:02 EST 2013"    I am looking for solution to read this date as 2013-12-25 and store it in a variable.  I have tried this:  a=`date --date=$Prev_date '+%y/%m/d'` echo $a   It's giving this error:  date: illegal option -- date=Wed usage: date [-u] mmddHHMM[[cc]yy][.SS] date [-u] [+format] date -a [-]sss[.fff]
68699
Following on from my previous question, , I have now come across a problem regarding the timezone, and it turns out that it's not always going to be "+0200". So when strptime tries to parse it as such, it throws up an exception.  I thought about just chopping off the +0200 with [:-6] or whatever, but is there a real way to do this with strptime?  I am using Python 2.5.2 if it matters.  &gt;&gt;&gt; from datetime import datetime &gt;&gt;&gt; fmt = "%a, %d %b %Y %H:%M:%S +0200" &gt;&gt;&gt; datetime.strptime("Tue, 22 Jul 2008 08:17:41 +0200", fmt) datetime.datetime(2008, 7, 22, 8, 17, 41) &gt;&gt;&gt; datetime.strptime("Tue, 22 Jul 2008 08:17:41 +0300", fmt) Traceback (most recent call last):   File "&lt;stdin&gt;", line 1, in &lt;module&gt;   File "/usr/lib/python2.5/_strptime.py", line 330, in strptime     (data_string, format)) ValueError: time data did not match format:  data=Tue, 22 Jul 2008 08:17:41 +0300  fmt=%a, %d %b %Y %H:%M:%S +0200
49528
How can two dates be compared in a shell?  Here is an example of how I would like to use this, though it does not work as-is:  todate=2013-07-18 cond=2013-07-15  if [ $todate -ge $cond ]; then     break fi                              How can I achieve the desired result?
56103
I currently have the following function: public String formatForGermany(Datetime targetTime) {     return this.format(targetTime, 'Europe/Berlin'); }  private String format(Datetime targetTime, String zone) {     Integer offset = TimeZone.getTimeZone(zone)             .getOffset(targetTime);     return targetTime.addSeconds(offset / 1000)             .format('HH:mm'); }  This works fine the input value is GMT. However, it seems in some contexts (TBD), Salesforce seems to anticipate this transformation is wanted and does it for me, in which case the offset gets applied twice, with the result that I display (for example) 14:00 instead of 12:00. Is there some way I can check whether the time has already been offset and either not apply it or adjust the offset accordingly?
45640
I have some issues about choosing how to align a Date/time data type in a field. Which is the best way to align this type of date and why? Right or left? P.S We use WPF.  [------25.03.2015] or [25.03.2015------]  Thank you :)
30685
I have a Timestamp value that comes from my application. The user can be in any given local TimeZone.  Since this date is used for a WebService that assumes the time given is always in GMT, I have a need to convert the user's parameter from say (EST) to (GMT). Here's the kicker: The user is oblivious to his TZ. He enters the creation date that he wants to send to the WS, so what I need is:  User enters: 5/1/2008 6:12 PM (EST)  The parameter to the WS needs to be: 5/1/2008 6:12 PM (GMT)  I know TimeStamps are always supposed to be in GMT by default, but when sending the parameter, even though I created my Calendar from the TS (which is supposed to be in GMT), the hours are always off unless the user is in GMT. What am I missing?  Timestamp issuedDate = (Timestamp) getACPValue(inputs_, "issuedDate"); Calendar issueDate = convertTimestampToJavaCalendar(issuedDate); ... private static java.util.Calendar convertTimestampToJavaCalendar(Timestamp ts_) {   java.util.Calendar cal = java.util.Calendar.getInstance(       GMT_TIMEZONE, EN_US_LOCALE);   cal.setTimeInMillis(ts_.getTime());   return cal; }   With the previous Code, this is what I get as a result (Short Format for easy reading):  [May 1, 2008 11:12 PM]
16097
I wrote a Javascript RegExp test to detect date string format, I added an redundant "g" flag by mistake and found something interesting.  var s = "2009/03/10"; var regex=/^\d{4}[/]\d{2}[/]\d{2}$/g; alert(regex.test(s)); alert(regex.test(s)); alert(regex.test(s)); alert(regex.test(s));   I got a 'true' followed by a 'false', then another 'true', then another 'false'.  If I use a loop to execute it, I found something more interesting, I got four "true" in IE and Safari, and true,false,true,false in FF, Chrome.  for (var i=0; i&lt;4; i++) {   var s = "2009/03/10";   var regex=/^\d{4}[/]\d{2}[/]\d{2}$/g;   alert(regex.test(s)); }   Does anybody has idea to explain why the Javascript regex behaves like that and what cause browsers return different results? ( related to variable declaration and life scope? )
44986
I have a String representation of a date that I need to create a Date or Calendar object from. I've looked through Date and Calendar APIs but haven't found anything that can do this other than creating my own ugly parse method. I know there must be a way, does anyone know of a solution?
57923
I wanted to use this, but I don't know if it's actually valid in English:     The specified date is invalid.It points to a non-existing day.   I'm not a native speaker, and I just want to say that the input points to a date that does not exist, like 30th February.
99897
I need to calculate if someone is over 18 from their date of birth using JQuery.  var curr = new Date(); curr.setFullYear(curr.getFullYear() - 18);  var dob = Date.parse($(this).text());  if((curr-dob)&lt;0) {     $(this).text("Under 18"); } else {     $(this).text(" Over 18"); }   There must be some easier functions to use to compare dates rather than using the setFullYear and getFullYear methods.  Note: My actual reason for wanting to find a new method is length of the code. I have to fit this code into a database field that is limited to 250 chars. Changing the database is not something that can happen quickly or easily.
2199
I use a datepicker for choosing an appointment day.  I already set the date range to be only for the next month.  That works fine.  I want to exclude Saturdays and Sundays from the available choices.  Can this be done?  If so, how?
107180
I found a great article on color coding a list item based on dates.  However, this only works for 2 days within submission.  I am trying to have a coding structure that will let me know when something is late.  This is the information I am using:   I have a column that subtracts the two dates, then I have another column that uses this script:   ="&lt;DIV style='font-weight:bold; font-size:24px; color:"&amp;CHOOSE((IF(SubmissionDateDifference&lt;=2,2,1)),"red","green","orange")&amp;";'&gt;•&lt;/DIV&gt;"   With this script, it is only given me the Red and Green colors depending on if the date is greater than 2 days or less than 2 days.  I would like to have it give me Red for 0 days and green for greater than 0.  When I tried to change the numbers to &lt;=0,0, the formula didn't work.  Also, the final piece in case you were wondering is setting up a web part with the list and below the list is a CEWP with this HTML Script:  &lt;script type="text/javascript"&gt; // // Text to HTML // Demo: sharepoint.infoyen.com by Avinash Kumar Dad // var cellTDs = document.getElementsByTagName("TD"); var i=0; var TDContent = " "; while (i &lt; cellTDs.length) { try { TDContent = cellTDs[i].innerText || cellTDs[i].textContent; if ((TDContent.indexOf("&lt;DIV") == 0) &amp;&amp; (TDContent.indexOf("&lt;/DIV&gt;") &gt;= 0)) { cellTDs[i].innerHTML = TDContent; } } catch(err){} i=i+1; } // // ExpGroupRenderData overwrites the default SharePoint function // This part is needed for collapsed groupings // function ExpGroupRenderData(htmlToRender, groupName, isLoaded) {    var tbody=document.getElementById("tbod"+groupName+"_");    var wrapDiv=document.createElement("DIV");    wrapDiv.innerHTML="&lt;TABLE&gt;&lt;TBODY id=\"tbod"+ groupName+"_\" isLoaded=\""+isLoaded+ "\"&gt;"+htmlToRender+"&lt;/TBODY&gt;&lt;/TABLE&gt;";    var tBODYTDs = wrapDiv.getElementsByTagName("TD"); var j=0; var cellTDContent = " ";    while (j &lt; tBODYTDs.length) {       try {          cellTDContent = tBODYTDs[j].innerText || tBODYTDs[j].textContent;          if ((cellTDContent.indexOf("&lt;DIV") == 0) &amp;&amp; (cellTDContent.indexOf("&lt;/DIV&gt;") &gt;= 0)) {            tBODYTDs[j].innerHTML = cellTDContent;          }      }      catch(err){}      j=j+1;   }   tbody.parentNode.replaceChild(wrapDiv.firstChild.firstChild,tbody); }     The link for this assistance came from    Any assistance will be greatly appreciated.
113519
I'm having a save method with several Conditions in it.Here is my apex class  invoiceset = [select SiteUrl__c, Prefix__c,Seperator__c,Seperator1__c,DateValue__c,DateValue1__c,Date_Format__c,Incrementer__c,Counter_Val1__c,counter__c from Invoice_setting__c limit 1];        if(invoiceSet[0].DateValue__c == 'Date' &amp;&amp; invoiceSet[0].DateValue1__c == 'Date'){         if(invoiceSet[0].Date_Format__c == 'dd-mm-yyyy'){              datenow = DateTime.now().format('dd-MM-yyyy');                   }else if(invoiceSet[0].Date_Format__c == 'MM-dd-yyyy'){              datenow = DateTime.now().format('MM-dd-yyyy');                     }else if(invoiceSet[0].Date_Format__c == 'dd/MM/yyyy'){              datenow = DateTime.now().format('dd/MM/yyyy');          }else if(invoiceSet[0].Date_Format__c == 'mm/dd/yyyy'){              datenow = DateTime.now().format('mm/dd/yyyy');          }else if(invoiceSet[0].Date_Format__c == 'yy'){              datenow = DateTime.now().format('yy');          }else if(invoiceSet[0].Date_Format__c == 'yyyy'){              datenow = DateTime.now().format('yyyy');          }           prefixName = invoiceset[0].prefix__c + invoiceSet[0].seperator__c + datenow + invoiceset[0].Seperator1__c + datenow;       }      else if(invoiceSet[0].DateValue__c == 'Counter' &amp;&amp; invoiceSet[0].DateValue1__c == 'Counter'){       if(invoiceSet[0].counter_val1__c == null){          invoiceSet[0].Counter_Val1__c = invoiceset[0].Counter__c;        }else if(invoiceSet[0].Counter_Val1__c == invoiceset[0].Counter__c){            intt = integer.valueof(invoiceSet[0].Counter__c) + integer.valueOf(invoiceSet[0].Incrementer__c) ;            invoiceSet[0].Counter_Val1__c = string.valueOf(intt) ;        }else {             intt = integer.valueof(invoiceSet[0].Counter_Val1__c) + integer.valueOf(invoiceSet[0].Incrementer__c) ;            invoiceSet[0].Counter_Val1__c = string.valueOf(intt) ;        }        update invoiceset;         prefixName = invoiceset[0].prefix__c + invoiceSet[0].seperator__c + invoiceSet[0].Counter_Val1__c + invoiceset[0].Seperator1__c +invoiceset[0].Counter_Val1__c;       } &amp;&amp; so on........   Inorder to cover all this conditions should I write those many methods or any other easy way?  Here is my Test Code  public static testmethod void test(){    invoice_setting__c setng = new invoice_setting__c(Name='Invoice Settings',SiteUrl__c='www.google.com',Prefix__c='Test',Seperator__c = '-',dateValue__c = 'Date',Seperator1__c = '/',dateValue1__c = 'Date',date_format__c='dd-mm-yyyy');     insert setng; } public static testmethod void test1(){     invoice_setting__c setng1 = new invoice_setting__c(Name='Invoice Settings',Prefix__c='Test',Seperator__c = '-',dateValue__c = 'Counter',Seperator1__c = '/',Counter_Val1__c=null,dateValue1__c = 'Counter',date_format__c='dd-mm-yyyy',Incrementer__c='10');     insert setng1; } &amp; so on......   Any Suggestions for this please
75120
In a visual force page, I can take a date and do this...  &lt;apex:outputText value="{0,date, MMMM d,  yyyy}"&gt;     &lt;apex:param value="{!relatedTo.my_date__c}"/&gt; &lt;/apex:outputText&gt;   I want to be able to do that in Apex code.  So I want a method which takes a date and returns a certain format as a string.  I check the API:   and sorry if I am stupid but not so obvious how to do this?  Many thanks.
58207
I am having date field in the UI. I have written code as per below      Datetime XXX = (Datetime)FieldName;     yyy= XXX.format('yyyyMMdd');   But after executing the batch date is decremented by 1 automatically  Can anyone suggest some idea??  Thanks in advance.